|
Posted by Curtis on 01/06/07 07:24
If you're trying to make thumbnails, you should actually resample the
images, otherwise, your web page will take a while to load, even if you
change the dimensions in the image tag.
See: http://php.net/manual/en/function.imagecopyresampled.php
On Jan 5, 10:01 pm, "eholz1" <ewh...@gmail.com> wrote:
> Hello PHP group,
>
> I am using some php code to check the size of images, and then
> resize or determine new dimension for the image. GD seems quite slow.
> It takes about 5 seconds (plus or minus) to calulate dimension for 7
> jpeg images.
>
> I have a 700mhz processor (Pentium III, remember those??)! with almost
> a gb of memory.
> Is that the way GD is??? Here is a snippet of the dode I use: I pass
> the image from an array to this function:
>
> function imageDimensions ($img) {
>
> //get size create an original image from file above
>
> $orig = imagecreatefromjpeg($img);
>
> if ($orig) {
>
> //get height and width
>
> $orig_x = imagesx($orig);
>
> $orig_y = imagesy($orig);
>
> $pic_size[0] = $orig_x; //width
>
> $pic_size[1] = $orig_y; //height
> if ($orig_x > 799) {
>
> $image_x = 800;
> }else{
> $image_x = $orig_x;
> }
>
> // $thumb_x = $_REQUEST['thumb_x'];
>
> $image_y = round(($orig_y * $image_x) / $orig_x);
>
> // $thumb_y = round(($orig_y * $thumb_x) / $orig_x);
>
> $pic_size[2] = $image_y;
>
> $pic_size[3] = $image_x;
>
> return $pic_size;
>
> //echo("Image width: " . $orig_x . ". Image height: " . $orig_y);
>
> } else {echo 'No Image!';
>
> }
> }I am open to any suggestions on improving my "code" as it were!
>
> Thanks for a good group,
> eholz1
[Back to original message]
|