Verifying images with getimagesize()
| From: | Edward Vermillion | Date: | Fri, 24 Jun 2005 15:09:45 +0000 |
| Subject: | Verifying images with getimagesize() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-217548@lists.php.net to get a copy of this message | ||
Sorry to reply to this message but I wanted the OP to find it too...
On Jun 23, 2005, at 9:42 AM, Jack Jackson wrote:
[snip]
Through your help I was able to validate image files using getimagesize() and have made a nice script to upload and rename images.[\snip] I've been meaning to post a reply to a problem I ran into a while back that included validating images with getimagesize(). I've seen a few posts from folks saying this is the way to go and just want to share my experiences. My original problem was that a script I had for batch generating thumbnails from uploaded images was running out of memory. With Richard Lynch's help I was able to track the problem to createimagefromjpeg() using an unholy amount of memory on one particular file, a file that had passed through getimagesize() with no problems. What I found was that if an image ( in this case a jpeg ) is corrupted, but just barely, getimagesize() will let it through. Just for the record I could open it up in Photoshop and that's how I discovered that it was corrupted, the last ten or fifteen rows on the image were gone. Photoshop showed an uncompressed file size of 11M for this image. But what I had to end up doing is setting my memory limit to 48M before createimagefromjpeg() could get enough memory to work with that it finally failed. Just a heads up to anyone that's using getimagesize() to verify an image before running it through createimagefromjpeg(), just because it passes getimagesize() doesn't necessarily mean it's a good image. Edward Vermillion evermillion@doggydoo.net