Re: Verifying images with getimagesize()

From: Date: Sat, 25 Jun 2005 15:41:25 +0000
Subject: Re: Verifying images with getimagesize()
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-217616@lists.php.net to get a copy of this message
Edward Vermillion wrote:
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 Thanks for telling me about that, Edward. I apprecate it. Actually in this case I was using it only to verify that it was something like an image to validate the file type before allowing it on the server. But you raise a very good point and I appreciate it.
JJ

« previous php.general (#217616) next »