note 21066 added to function.imagecopyresized
| From: | bill at nospam dot puetz dot com | Date: | Sat, 27 Apr 2002 07:56:19 +0000 |
| Subject: | note 21066 added to function.imagecopyresized | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29908@lists.php.net to get a copy of this message | ||
Is it possible to use ImageCopyResized to resize an image without stretching? I want to create
thumbnails of a maximum size of 120x100. But when I use the code below, some images look really bad
because the original dimensions weren't the same proportion. So I would like to create the
largest proportional thumbnail I can within the 120x100 limit. Any pointers on how to do this?
Here's the code I'm using now:
$im = ImageCreateFromJPEG( $scrFile );
$srcW = ImageSX( $im );
$srcH = ImageSY( $im );
$ni = ImageCreate( $dstW, $dstH );
ImageCopyResize( $ni, $im, 0, 0, 0, 0, $dstW, $dstH, $srcW, $srcH );
ImageJPEG( $ni, $dstFile );
--
http://www.php.net/manual/en/function.imagecopyresized.php
http://master.php.net/manage/user-notes.php?action=edit+21066
http://master.php.net/manage/user-notes.php?action=delete+21066
http://master.php.net/manage/user-notes.php?action=reject+21066