homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

getimagesize() different types of JPEG return false

5+ Year Member

Msg#: 4001455 posted 2:57 pm on Oct 5, 2009 (gmt 0)


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?




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

Msg#: 4001455 posted 5:26 pm on Oct 5, 2009 (gmt 0)

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.)


5+ Year Member

Msg#: 4001455 posted 7:17 pm on Oct 5, 2009 (gmt 0)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved