homepage Welcome to WebmasterWorld Guest from 54.81.170.186
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
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
tomhumf




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

Hi,

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?

Thanks

 

rocknbil




msg:4001614
 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.)

tomhumf




msg:4001688
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved