CodeIgniter Forums

Full Version: image_width & image_height are blank on upload
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I have an intermittent image uploading issue that I can't seem to track down an answer for.

I'm doing simple single image uploads. The files upload just fine in all cases. Then I attempt to access the upload data to determine height and width. Most of the upload data is populated, but height and width are blank. This only happens for some images, others work just fine.

Anyone point me in the right direction? Any thoughts? There's something I'm not seeing here.

Here's an example of the upload data I receive:

[upload_data] => Array (
[file_name] => example.jpg
[file_type] => image/jpe
[file_path] => path/to/file/
[full_path] => path/to/file/example.jpg
[raw_name] => example
[orig_name] => example.jpg
[client_name] => myPic.jpg
[file_ext] => .jpg
[file_size] => 568.02
[is_image] => 1
[image_width] =>
[image_height] =>
[image_type] =>
[image_size_str] =>

I found one image file attribute that may be the culprit. On all the files that fail, the "color representation" property is "sRGB". On the files that work, that property is not set at all. Doesn't seem like something that should trip up GD or ImageMagick, but it's the only thing I can find. I'll keep digging

El Forum

Through a lot of trial and error I found the cause of the issue, but not the solution. However, from what I can tell, the cause is linked to Amazon's S3 storage, not CodeIgniter or PHP. So I'm considering this question answered since it's not a CI issue.

In a nutshell, here's what I found. Since Codeigniter uses 'getimagesize' just like you would in straight PHP, I started testing outside of CI just calling getimagesize on different JPEGS.

When accessing images stored locally on the server/instance, everything works fine, no matter what their properties.

When I access images on Amazon's S3 storage, the JPEGS whose "color representation" property is set to "sRGB" cause getimagesize to return false. Those without the property set work just fine.

So something about storing the images on S3 is causing an issue. But that's a subject for a different forum..