Click to See Complete Forum and Search --> : Pic resize script needs file types added...


HDC
02-17-2007, 08:31 AM
I have a script below that resizes a jpg images. Currently only jpg files work. Can anyone tell me how to get .gif, .png, and possibly .tif and .pdf pictures to work in this script.

Thanks!


<?php
// The file
$filename = $_REQUEST['photo'];
$wid=625;

// Content type
header('Content-type: image/jpeg');
header('Content-length: '.filesize($filename));

// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $wid;
$widthratio = $new_width / $width;
$new_height = $height * $widthratio;

// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

// Output
imagejpeg($image_p, null, 100);
?>

bokeh
02-17-2007, 10:28 AM
It's amazing what a search digs up: function resize (http://webdeveloper.com/forum/showpost.php?p=579825&postcount=19)!

NightShift58
02-17-2007, 11:04 AM
There you go... cheating again... Incorrigible...

bokeh
02-17-2007, 12:21 PM
There you go... cheating again... Incorrigible...That's part of the 95% of code I told you about! What should I have done differently?