Resizing image files

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-23-2003
Chris Langley
 
Posts: n/a
Default Resizing image files

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



Reply With Quote
  #2 (permalink)  
Old 10-23-2003
pouzzler
 
Posts: n/a
Default Re: Resizing image files

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 ;)
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:10 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0