Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

iPad / iPhone Orientation (exif orientation tags) #190

Closed
AdrianSchneider opened this Issue Jan 23, 2013 · 23 comments

Comments

Projects
None yet

When an image is uploaded directly from an iPad or iPhone without going through a computer first, the image is not properly rotated. Usually the computer will apply transformations automatically upon import, but with a direct upload the image library will need to detect these tags and rotate the image automatically.

(sample code - http://php.net/manual/en/function.exif-read-data.php#110894)

Any thoughts?

Owner

avalanche123 commented Jan 23, 2013

I think it would be a useful feature

chadkoh commented Jan 23, 2013

Yeah this is going to be a common thing going forward since more and more people are uploading directly "from camera" so to say. Kudos to @avalanche123 for replying quickly.

Collaborator

romainneutron commented Jan 23, 2013

Hello there,

some self promo here : I wrote http://github.com/romainneutron/MediaVorus earlier. It needs some love but it works rather pretty well for the moment. It's based on Phil Harvey's exiftool and it can extract such properties :

{
  "type": "Image",
  "raw_image": false,
  "multiple_layers": false,
  "width": 3264,
  "height": 2448,
  "channels": 3,
  "focal_length": 4.28,
  "color_depth": 8,
  "camera_model": "iPhone 4S",
  "flash_fired": false,
  "aperture": 2.4,
  "shutter_speed": 0.05,
  "orientation": 90,
  "creation_date": "2012:03:16 16:29:09",
  "hyperfocal_distance": 2.0773522348635,
  "ISO": 400,
  "light_value": 4.847996906555,
  "color_space": "RGB"
} 

There's a bit of documentation here http://mediavorus.readthedocs.org/en/latest/ but as I already said, it needs some love.

So, if anyone works on such PR in Imagine, I think could be awesome to incorporate a detection strategy based on exif PHP extension that could be replaced by another strategy.

lmcd commented Jan 24, 2013

+1 - I'm building a mobile app in Symfony leveraging Imagine via LiipImagineBundle. Whenever an Image is uploaded from the device's camera or photo library, it almost always ends up being upside down.

Collaborator

romainneutron commented Jan 31, 2013

Hey, guys, any of you ready to work on this ?

lmcd commented Feb 6, 2013

I threw this together as I needed this feature quite desperately:
https://github.com/lmcd/Imagine/commits/autorotate

Owner

avalanche123 commented Feb 6, 2013

Your implementation looks great. I'm wondering if we should just autorotate automatically from Imagine::open directly? That way we wouldn't need autorotate method at all, and this would be a documented feature of Imagine.

+1
Is there any chance to add this quickly? I have the same problem as lmcd - photos uploaded from mobile devices.

jdelaune commented Apr 7, 2013

+1 Would love it to get auto-rotated on open.

Contributor

bamarni commented Jul 17, 2013

What about Imagine::load()?

exif_read_data() can also work with binary data apparently (see http://stackoverflow.com/questions/5465665/extract-exif-data-from-an-image-blob-binary-string-in-php).

Collaborator

romainneutron commented Jul 17, 2013

Nice ! Thanks for the suggestion

mumia commented Jul 19, 2013

Is this fix stopped? I'm having the same problem with a lot of photos and this would just make it all go away.

Collaborator

romainneutron commented Jul 19, 2013

Hello @mumia ,

this feature request should not block you. The following code should solve it :

$exifData = exif_read_data('image.jpg');
switch($exifData['Orientation']) {
    case 8:
        $rotateVal = -90;
        break;
    case 3:
        $rotateVal = 180;
        break;
    case 6:
        $rotateVal = 90;
        break;
}
$image->rotate($rotateVal, $color);

mumia commented Jul 19, 2013

Yes, was just going to start looking into a fix for this problem.
Thanks for the code snippet. :)

Collaborator

romainneutron commented Jul 19, 2013

A fix is on its way in #222

+1 I'm writing an iphone app with symfony backend and it would really be awesome to have Imagine threat exif rotation transparently

I'm missing this feature as well for a website where users will upload images directly from their mobile devices.

Collaborator

romainneutron commented Nov 25, 2013

No need for a hack or a fix, you can use @frickelbruder filter until metadata support will be merged, see https://raw.github.com/frickelbruder/Imagine/develop/lib/Imagine/Filter/Advanced/CorrectExifRotation.php and #222

Thanks :)

arjoe commented Mar 11, 2014

+1 Any plans to merge @romainneutron PR? I would really like to see auto rotate support included.

@romainneutron Great work! Thank you! Would also appreciate to merge it.

@romainneutron romainneutron added a commit to romainneutron/Imagine that referenced this issue Apr 9, 2014

@afoeder @romainneutron afoeder + romainneutron [FEATURE] Introduce image metadata
This introduces `metadata` as a gettable property of
the `ImageInterface` and its implementations, in order
to carry initial image metadata along the lifecycle.

The distributed implementation determines the metadata
by the image's EXIF information, but it not limited to
this in the future.

This is a preparation for #222 and related to #190.
55d4da5

@romainneutron romainneutron added a commit to romainneutron/Imagine that referenced this issue Apr 9, 2014

@afoeder @romainneutron afoeder + romainneutron [FEATURE] Introduce image metadata
This introduces `metadata` as a gettable property of
the `ImageInterface` and its implementations, in order
to carry initial image metadata along the lifecycle.

The distributed implementation determines the metadata
by the image's EXIF information, but it not limited to
this in the future.

This is a preparation for #222 and related to #190.
15918d1

@romainneutron romainneutron added a commit to romainneutron/Imagine that referenced this issue Apr 9, 2014

@afoeder @romainneutron afoeder + romainneutron [FEATURE] Introduce image metadata
This introduces `metadata` as a gettable property of
the `ImageInterface` and its implementations, in order
to carry initial image metadata along the lifecycle.

The distributed implementation determines the metadata
by the image's EXIF information, but it not limited to
this in the future.

This is a preparation for #222 and related to #190.
25c4c91
Collaborator

romainneutron commented Apr 21, 2014

I'm happy to close this issue, it's been fixed in 447b572

Feedback welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment