This is a discussion on Resizing image files within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello everyone, Is there a way to resize an image file, save it in it's new format and then ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello everyone,
Is there a way to resize an image file, save it in it's new format and then upload it to a server ? I've been through a few tutorials, that don't work... I can figure out the uploading part, but the resizing and then saving illudes me. Any help would be great. Chris |
|
|||
|
function PzMakeThumb()
{ $handle = opendir('./img'); while (false !== ($filename = readdir($handle))) { if ($filename != "." && $filename != "..") { $size = getimagesize("./img/$filename"); $src_width = $size[0]; $src_height = $size[1]; $dest_height = 100; $dest_width = $dest_height*$src_width/$src_height; $src_img = imagecreatefromjpeg("./img/$filename"); $dst_img = imagecreatetruecolor($dest_width,$dest_height); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); imagejpeg($dst_img, "./thumbs/$filename"); imagedestroy($src_img); imagedestroy($dst_img); } } } This function makes thumbs of all the 'img' dir with a thumb height of$dest_height It takes awful lots of time though ;) |