note 35165 deleted from function.imagecopyresampled by aidan
| From: | aidan@php.net | Date: | Mon, 04 Oct 2004 09:44:28 +0000 |
| Subject: | note 35165 deleted from function.imagecopyresampled by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77956@lists.php.net to get a copy of this message | ||
Note Submitter: Improved use of Thumbnail Formula
----
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...