Closed (fixed)
Project:
ImageCache Actions
Version:
6.x-1.x-dev
Component:
Canvas Actions Module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
31 Aug 2009 at 13:44 UTC
Updated:
28 May 2010 at 11:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
moover commentedMoved to right project.
Comment #2
moover commentedComment #3
dman commentedActually, I heard about this being done just recently.
I've been getting deep deep into EXIF and metadata, extracting info that then gets exposed or becomes a parameter on the imagecache process (mostly intextactions - to label them with captions and stuff)
BUT ... I have not yet seen what this rotation tag might be, and what it looks like. Basically my camera doesn't do that, so I'm in the dark about what this is supposed to work like.
Any hints?
Comment #4
moover commentedIt was just would be nice thought since picasa is able to know the rotation of images on my desktop without any input from me. If you want an image that has the info i can get you one no problem.
Comment #5
moover commentedQuick browse and I found exiftool http://www.sno.phy.queensu.ca/~phil/exiftool/ which used on one of my pictures shows a variety of output including "Orientation: Rotate 90 CW"
Comment #6
moover commentedFile with 90 degree CW rotation tag available at http://moover.co.uk/irvinestown/P1020148.JPG. Couldn't upload it here since it's bigger than 1M.
Comment #7
moover commentedUseful reading: http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
TagID 0x0112
TagName Orientation
Writable int16u
Group IFD0
1 = Horizontal (normal)
2 = Mirror horizontal
3 = Rotate 180
4 = Mirror vertical
5 = Mirror horizontal and rotate 270 CW
6 = Rotate 90 CW
7 = Mirror horizontal and rotate 90 CW
8 = Rotate 270 CW
Comment #8
dman commentedMy previous work with metadata from images
Code is in my sandbox
... currently tuned towards adding text from metadata fields, but if you paste up one of those images you describe, I'll see if we can find and expose the value.
jonathan_hunt said he had an implementation of this task last month. I didn't take him up on it at the time...
Comment #9
dman commentedTagName Orientation - OK, THAT is a useful reference.
I know that site - strange that it's the only/best EXIF reference out. Bloody intimidating list of random crap from various manufacturers!
Comment #10
dman commentedDammit. My meta_inspector can see the value, but something internal (PHP - exif function?) is already translating it to English.
Scanning the node for meta fields I get:
... which is correct, but I'd rather trust the constant...
... Ah, It's my code, I've got the choice available to me... Hm, how to expose both? I'll see...
Comment #11
jonathan_hunt commentedFYI, here's the code I have. It might be a useful starting point. It only works on JPEGs for now. It's sufficient for my purposes; I'm using it to autorotate photographs submitted by iPhone and Android to FixMyStreet.org.nz
Comment #12
dman commentedThanks Jonathan, that looks WONDERFULLY simple.
And it's just sweet as a standalone one-action module.
I might just add a paragraph of documentation, but I'd be happy to roll that into the distro if that's OK with you?
Comment #13
dman commentedActually, on test, that code turned that sample image upside-down!
So it's TRYING ... but I need to review those constants ;-)
Comment #14
jonathan_hunt commentedDoh, I haven't seen that happen. Can you share the test image?
Comment #15
dman commentedThat one in this issue: http://moover.co.uk/irvinestown/P1020148.JPG
I don't HAVE any others with that info embedded :0)
edit --- Damn, the sample has gone away.
edit --- damn, I can't edit my local copy of that sample down to a decent size WITHOUT it autocorrecting the orientation in PS, FW, Gimp, Xee .... Maybe I'll try imagemagick
Comment #16
dman commentedthis one went through. Same EXIF tags as the orig
Comment #17
moover commentedSorry, was tidying up. Will stick up some test images for you later.
Comment #18
moover commented4 images in http://moover.co.uk/testimages/
I rotated the camera through the four 90 degree increments
Picasa rotates each one correctly on preview to have the arrow pointing up
Comment #19
dman commentedCool I'm seeing what I should see.

Screenshot shows teasers containing a normal thumbnail, and an embedded, autorotated (scaled) imagecache version of the same.
Comment #20
dman commentedI've committed that to CVS then, please try it out.
Because I've had to swap the rotate-left, rotate-right behaviour from jonathans original (to get the correct result above), I'm harbouring doubts that some cameras may disagree about rotation - does "rotated clcokwise" mean the camera or the image went clockwise? :-)
Comment #21
moover commentedHave upgraded to latest dev snapshot but don't see any rotation happening. Is there a config to turn this on? Thanks
I'd have thought the rotation tag is the rotation needing applied to the image to make it upright eg the original image posted in this thread needs 90 clockwise to make it display right. Just a guess - i've not looked into it and I've not got images from a second camera with the tag to test.
Comment #22
dman commentedIt's an action you can turn on.
visit admin - modules.
enable 'imagecache autorotate'
visit or create an imagecache preset
enable 'autorotate' as an action in that preset
Comment #23
moover commentedNot seeing AutoRotate as an option in the actions list. I upgraded from the stable release, though when i ran the updates script it didn't say the usual "... upgraded 1...", it was ".... upgraded 0...". Dev version looks installed ok, the right version is picked up in the module available updates page.
Any ideas what i did wrong? Thanks
Comment #24
dman commentedimagecache_actions is a collection of smaller modules. "Imagecache Autorotate" needs to be turned on explicitly.
It's possible that imagecache is caching things too hard again. :(
Yeah, could be. OK, for no good reason ...
1. disable canvasactions, or an existing unused actions module.
2. uninstall it! using admin/build/modules/uninstall (don't delete anything)
3. enable it again.
That should have fooled imagecache enough.
I'm rolling in a hard cache-flush to the module install function now. imagecache is annoying that way.
Comment #25
moover commentedThat's the business now. Working well for me. Didn't realise it was a separate module in the module list that needed enabled. Can't say whether or not it was there after first upgrade but it was after following your instructions. Thanks again.
Comment #26
dman commentedBecause it's such a rare case, and because conceptually I don't really know where to put it, and because jonathan_hunt supplied it as a tiny, working, stand-alone optional module ... it's on its own for now.
I don't want to proliferate small modules too much, but OTOH, it's unlikely that any sane site would want more than two or three effects in effect at once, so I don't want to bulk out the extras either. Not sure where to draw the line, but in the meantime, smaller and modular is easier to keep track of changes in :-)
Comment #27
dman commentedFYI, I was just reading National Information Standards Organization (NISO) Z39.87 Technical Metadata for Digital Still Images for fun*.
And found a fuller description on page 70:
I interpret "the orientation value of the stored image" and "6 = normal, rotated ccw 90° " to mean the image is currently 90° ccw and to transform it for accurate display, we must turn it back 90° cw
Which is what the code I modified currently does
I think we are right.
I'm a little concerned that that wasn't the case with the version that was working for jonathan, so I won't stake my life on it, but I'll bet 5:1 odds.
* - Actually I was reading up on Library of Congress MARC Data Schemes and that 171-page document on image encodings was comparatively light reading!
Comment #28
momper commentedsubscribe
Comment #29
David Stosik commentedHello,
I just tested the module "as is", with four photos I just shot.
My explorer rotates them correctly (although it seems my camera doesn't handle upside down shooting...), so I suppose the EXIF data is OK.
When I upload my photo, here are the debugging messages I can get :
imagecache_autorotate_image: exif[Orientation]=8
imagecache_autorotate_image: rotating degrees=270
for the first and
imagecache_autorotate_image: exif[Orientation]=6
imagecache_autorotate_image: rotating degrees=90
So, by checking there, I conclude that imagecache_autorotate did its job...
BUT !
These two images are upside down, as if they were rotated counter clock wise...
I am using ImageAPI GD, have just one preset, containing Autorotate only.
Does anyone know what could be my problem ?
Thanks,
David
Comment #30
David Stosik commentedOkay, I just found that imageapi_gd_image_rotate() does this call:
$image->resource = imagerotate($image->resource, 360 - $degrees, $background);Why does it use 360 - $degrees ? I don't know, but if I but $degrees instead, it works...
Edit : OK, my issue seems related to #373631: gd_rotate() rotate wrong way for 90° and 270°
Comment #31
dman commentedclosing, based on the conclusion found in #373631: gd_rotate() rotate wrong way for 90° and 270°#13
- Status page reported gd does not support rotation.
Odd that this means it does, but brokenly
Comment #32
dman commentedstatus
Comment #33
David Stosik commentedHello,
Actually, this issue concerns the implementation of autorotation.
Shouldn't you wait a stable release to close this issue ?
Thanks,
David