note 35165 added to function.imagecopyresampled
| From: | Improved at rack1 dot php dot net | Date: | Thu, 21 Aug 2003 19:55:52 +0000 |
| Subject: | note 35165 added to function.imagecopyresampled | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54835@lists.php.net to get a copy of this message | ||
I tried the suggestion in the post below but although it's a neat idea, I found that some
images gave faulty sizes. I rebuilt the code as follows and so far have had no such problems.
<?php
$image_details = getimagesize("$dir_name/$image");
$imagesize_x = $image_details[0];
$imagesize_y = $image_details[1];
$thumbsize_x = 100;
$thumbsize_y = 75;
$thumb_x = round(($imagesize_x * $thumbsize_y)/$imagesize_y);
if ($thumb_x > $thumbsize_x)
{
$thumb_x = $thumbsize_x;
$thumb_y = round(($imagesize_y * $thumbsize_x)/$imagesize_x);
}
else
{
$thumb_y = $thumbsize_y;
}
echo "Projected Thumbnail Size to fit within $thumbsize_x x $thumbsize_y = $thumb_x x
$thumb_y";
?>
I hope this helps...
----
Manual Page -- http://www.php.net/manual/en/function.imagecopyresampled.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35165
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35165&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35165&report=yes