Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

getimagesize() different types of JPEG return false



2:57 pm on Oct 5, 2009 (gmt 0)

5+ Year Member


I'm working on an upload image script. It works for most .jpg files. The problem is with ones that are from a digital camera I think. In these cases getimagesize() returns false.

I've read that there are a few types of .jpeg files, but can't find a way to convert them all to a type that works with getimagesize().

The files that don't work have large dimensions, like a few thousand px, so I thought it could be a memory problem...but I don't get any error about memory. They also don't return any info for exif_imagetype().

Does anyone know if it's possible to convert these somehow to a format that getimagesize() will accept?



5:26 pm on Oct 5, 2009 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

First you need to determine the problem, exactly. If they are coming hot off a camera, it's possible it's dying on upload if they exceed 2MB. If you've tweaked the system to allow files larger than 2MB, most GD toolkit functions create a full bitmap of the image in memory.

What that means is a compressed file - JPG - is turned into a literal bitmap uncompressed file in memory, which can be huge, and which will definately kill your server on larger images due to memory usage. For large manipulations like this you'll need to use Imagick and ImageMajick.

A third possibility is newer jpg versions may not get recognized, but I don't know a whole lot about the specifics of this (and may be a goose chase.)


7:17 pm on Oct 5, 2009 (gmt 0)

5+ Year Member

Hmm. It's not hot off a camera and it's definetly getimagesize function which returns false, it does a check at the start of the script. The image does load in image editors so I know it must be some kind of valid jpg.

upload_max_filesize is set to 24M according to my cpanel. I'm on shared hosting so I guess Imagick and ImageMajick aren't an option because they don't seem to be supported.

Thanks for the suggestions anyway, I'll do some more reading. The images are quite old so maybe they are just freaks and I shouldn't worry about them...just ask users to upload a different kind or something.


Featured Threads

Hot Threads This Week

Hot Threads This Month