Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

FN-FORUM: Creating thumbnails

date posted 9th March 2006 17:09

Hello All,

I have built an image library application (PHP/MySQL) which customers
use to upload pics to their sites within their CMS. It has a function
thumbnail() (see code below) which converts the full-size image to a
thumbnail for showing in the "gallery" view. The function uses NetPBM
tools to do the image manipulation.

I'm in the process of moving all my sites to a new server. The new
server doesn't have NetPBM tools installed, but it does have the GD
library. However I have read that GD does not support gif:

>> (gd does not support GIF anymore, because the packing algorithm in
>> GIF is copyrighted).

Obviously my customers will want to use gif.

Any idea how to get around this?


Best regards,

Ray

------------------------------
Ray McGinty Information Design

Specialising in web application development,
e-commerce and design for print.

http://www.rmid.co.uk

Listed on the National Business Link Consultants Register

> /*
> * The thumbnail function uses the pnmscale program from
> * the popular Netpbm image manipulation tools package
> * to create a thumbnail of the given image. If a thumbnail
> * already exists for the image, the function simply returns.
> * Script amended to create thumbnail even where one already exists.-
> RM 2.8.02
> */
> cfunction thumbnail($filename) {
>
> global $x_dim;
> global $y_dim;
> global $images_folder;
> /* Define where to find the various external binaries we need
> */
> $djpeg = "/usr/bin/djpeg"; /* decompresses a jpeg to ppm
> */
> $cjpeg = "/usr/bin/cjpeg"; /* compreses a ppm to jpeg format */
> $pnmscale = "/usr/bin/pnmscale"; /* scales a ppm image */
> $giftopnm = "/usr/bin/giftopnm"; /* convert a gif to ppm */
> $ppmtogif = "/usr/bin/ppmtogif"; /* convert a ppm to gif */
> $ppmquant = "/usr/bin/ppmquant"; /* colour quantize a ppm */
>
> $tdir = dirname($filename)."/thumbnails"; /* thumbnail
> directory */
>
> if(!filetype($tdir)) {
>
> // echo "Creating thumbnails directory \$tdir $tdir ";
> [EMAIL REMOVED] {
> echo "Unable to create $tdir dir - check
> permissions\n";
> return;
> }
>
>
> }
> $tfile = $tdir."/".basename($filename); /* thumbnail file
> */
>
> // if(!filesize($tfile)) {
> if(eregi("\.gif$",$filename)) { /* Look for .gif
> extension */
> exec("$giftopnm $filename | $pnmscale -xysize $x_dim $y_dim ".
> "| $ppmquant 256 | $ppmtogif -interlace >
> $tfile");
>
> } elseif(eregi("\.jpe?g",$filename)) { /* Look for .jpg or
> .jpeg */
> exec("$djpeg $filename | $pnmscale -xysize $x_dim $y_dim | ".
> "$cjpeg -outfile $tfile");
>
> } else { /* not a GIF or JPG file */
> return("");
> }
> // }
> return($tfile);
> }



Messages by Day
March 31st 2006
March 30th 2006
March 29th 2006
March 28th 2006
March 27th 2006
March 26th 2006
March 25th 2006
March 24th 2006
March 23rd 2006
March 22nd 2006
March 21st 2006
March 20th 2006
March 19th 2006
March 18th 2006
March 17th 2006
March 16th 2006
March 15th 2006
March 14th 2006
March 13th 2006
March 12th 2006
March 11th 2006
March 10th 2006
March 9th 2006
March 8th 2006
March 7th 2006
March 6th 2006
March 5th 2006
March 4th 2006
March 3rd 2006
March 2nd 2006
March 1st 2006


Messages by Month
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000