Hi, Wednesday, March 23, 2005, 11:30:53 PM, you wrote: RA> Hi, RA> I found this beautiful piece of code on the php site which make a RA> proportional thumbnail, problem is its only working with JPEG files...and RA> not with GIFs, can someone please help me convert it to GIF too? RA> I tried but got a bit confused as there are no functions that are equal to RA> "imagecreatetruecolor" that is in the below script. RA> The below script works perfectly for jpgs: Here is a function I use for scaling that you can use as an example,it also handles transparent gifs. You can set $x or $y leaving the other at 0 to maintain aspect ratio or set both to force a fixed box. function Scale($input,$out,$x,$y){ $info = getimagesize($input); $width = $info[0]; $height = $info[1]; $colors = array(); if($width > 0 && $height > 0){ if($x > 0){ $w2 = $x; if($width > $w2){ $scale = $width/$w2; $h2 = intval($height/$scale); }else{ $scale = $w2/$width; $h2 = intval($height * $scale); } }elseif($y > 0){ $h2 = $y; if($height > $h2){ $scale = $height/$h2; $w2 = intval($width/$scale); }else{ $scale = $sw2/$height; $w2 = intval($width * $scale); } } switch($info[2]){ case 1: $im = ImageCreateFromGif($input); $t = ImageColorTransparent($im); $itype = "gif"; if($t != -1){ $colors = imagecolorsforindex($im, $t); } $im2 = ImageCreate($w2,$h2); break; case 2: $itype = "jpeg"; $im = ImageCreateFromJpeg($input); $im2 = ImageCreateTrueColor($w2,$h2); break; case 3: $itype = "png"; $im = ImageCreateFromPng($input); $t = ImageColorTransparent($im); if($t != -1){ $colors = imagecolorsforindex($im, $t); } $im2 = ImageCreateTrueColor($w2,$h2); break; default: return; break; } if(count($colors) > 0){ $transp = ImageColorAllocate($im2, $colors["red"],$colors["green"], $colors["blue"]); } imagecopyresampled($im2, $im, 0, 0, 0, 0, $w2, $h2, $width, $height); if(count($colors) > 0){ ImageColorTransparent($im2,$transp); } if(eregi("\.gif$",$out)){ ImageGif($im2,$out); }elseif(eregi("\.jpe?g",$out)){ ImageJpeg($im2,$out,90); }elseif(eregi("\.png$",$out)){ ImagePng($im2,$out,20); } } } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php