this has got me baffled: imagesx() and imagesy() reporting the wrong size?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On my site I have a web form for users to upload graphics, however there are constraints on the size allowed. Recently, a user has been having problems, because the code is reporting the wrong size - a size too small to be allowed! They sent me a copy of the image so I could confirm the error, and I have: even though the image is a 32x32 image (2-frame animated GIF, if it matters), imagesx() and imagesy() report that the image is 30x24! I have never had this problem before (or, at least, no one has reported it to me) so I'm tempted to think that it's a bug in PHP, or (more likely) I am missing something crucial...

The relevant code:

if($itype == 'image/gif')
  $img = imagecreatefromgif($_FILES['file']['tmp_name']);
else if($itype == 'image/png' || $itype == 'image/x-png')
  $img = imagecreatefrompng($_FILES['file']['tmp_name']);

// note: we do not get here if($itype != 'image/gif' && $itype !=
// 'image/png' && $itype != 'image/x-png'), so the problem should not
// lie with an image type we were not expecting

$w = imagesx($img);
$h = imagesy($img);

if(!(($w == 48 && $h == 48) || ($w >= 4 && $w <= 48 && $h == 32)))
{
  $error = 'The graphic\'s dimensions are not correct (' .
           $w . 'x' . $h . ').';
}
else
{
  ...
}

yes, the logic wants either a 48x48 graphic, or a 4x32 to 48x32 graphic.

I'd be happy to link the animated GIF in question... just in case there was a problem with the GIF itself, I tried opening it up in an (old) version of Fireworks, and re-exporting it, but the problem remains.

besides the possibility of a bug in PHP, I'm wondering if I need to handle animated GIFs differently, or something like that? but again, this code has been running for... 3ish years without a problem like this ever being reported... quite confusing.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux