Murphy Mac - Screencasts and Tutorials » Page 'iPhone Photo Rotation – Part Two'

iPhone Photo Rotation – Part Two

Share

beautifulMurphy already posted about issues with mailing vertically-oriented photos from your ios4 iPhone:  Chances are your recipient sees the photo rotated 90 degrees to the left.  Web browsers – Safari included – don’t know how to read the exif orientation tag included with the jpg file.

My previous solution was to use an alternate camera app.  But I’ve got another approach that requires a Mac running Mail.

When I take a photo with my iPhone – in portrait orientation – I simply email it to myself.  My Mac is configured to watch for email with a particular subject and then automatically grab the attachment, strip the exif rotation information, and rotate the photo without using a tag.  Then my Mac mails the photo back to me.

Here’s the setup:

In Finder

In your home folder create a folder called lab with subfolders in and out.  Like this:

/Users/murphy/lab/in

/Users/murphy/lab/out

AppleScript

Download my AppleScript.  Edit the AppleScript and change all occurrences of ‘murphy” to the name of your home folder.  There are notes in the script to help you.

Automator

WorkflowCreate an Automator workflow.  You’ll need to add 4 actions in the same order they’re listed below.

  • Mail: New Mail Message
  • Finder: Get Specified Finder Items
  • Mail: Add Attachments to Front Message
  • Mail: Send Outgoing Messages

Only the first two Automator elements need further configuration.  The first one defines the address your altered photo will be emailed to.  You might add a subject as well.

Then specify this file path in the Finder element:

/Users/murphy/lab/out/outbound.jpg

Make sure you replace “murphy” with your home folder name.  The path points to the photo Automator will mail back to you. Save as a workflow. The AppleScript expects the workflow to be in a folder called _applescripts in your Documents folder. Edit the AppleScript if your workflow will be stored somewhere else.

Mail

WorkflowIn Mail you need a rule to kick off the AppleScript when a message arrives meeting certain criteria.  My rule looks like this screenshot.  The script runs when an email arrives with the subject “rotate”.  You might select a different word or phrase.  Make sure you set the script path to the location where you saved your AppleScript. More on Mail rules.

jhead

The AppleScript relies on a command line utility called jhead to strip the exif rotation tag, which I found in this TUAW post.  My script expects jhead to be in the /Users/murphy/lab/in folder.  After downloading jhead you’ll need to make it executable.  In the Terminal:

chmod +x path/to/jhead

In my case I entered chmod +x /Users/murphy/lab/in/jhead

That’s about it.  My script pulls the photo from the email, rotates it, strips the exif rotation information, copies it to another folder, and kicks off an Automator workflow to mail the photo back to me.

When I receive the altered photo on my iPhone I can simply forward it to someone.  If they view it in web Gmail they’ll see the photo inline-style within the email.  I prefer to save the photo to my camera roll and send it from there.  That way I’m prompted to select a size and recipients using web-based gmail get a thumbnail with a choice to view or download.

Notes

You might want to place jhead somewhere other than where I did.  If you move it you’ll need to edit the AppleScript.

Mail needs to be running on your Mac for this to work.

I used an Automator workflow to send the return email.  You can do it in AppleScript if you prefer, but I’ve had mixed results down that road.  Decided to try Automator.

You could use Automator to extract the attachment.  I’d already written a script to extract an attachment from Mail so it seemed like the way to go.

You could alter the AppleScript so everything happens in one folder.  I used two folders only to help me with troubleshooting the script the first time through.

Don’t forget to make jhead executable.

Dropbox Alternative

Here’s another alternate solution:  Dropbox

You could upload your images to Dropbox from your iPhone – then mark them as a favorite.  From there you copy the image to the clipboard to paste into a mail or save it down to your camera roll.   They won’t be full-size though.  And if you paste and mail it’ll be sent as a png.  But the orientation will be correct.  If you simply upload and send the link the orientation will be wrong.

OR

You could use something like my script above to place a full-size copy of your file in your Mac Dropbox.  Then you can access the photo from the Dropbox app on your iPhone.  You’ll still need to copy and paste or save it to the roll to get the rotation right.

perfect Yeah – it’s a lot to set up and you need a Mac running to use it. I can wake my Mac up from my phone so that’s not a big deal. And I find mail-based workarounds like this convenient to use. Still – maybe Apple should switch back to the old way until the browsers catch up.

Script Download | Permalink

6 comments to “iPhone Photo Rotation – Part Two”

  1. Just saw you can adjust Dropbox upload quality. Need to update this post…

  2. Set the orientation to how you want it, take a screen snapshot (just press the Home and Sleep buttons at the same time) and then email that new photo. No guarantees about quality, but it is a fast fix.

  3. Have arrived at this post, nearly 2 years after it was posted, trying to find a solution to this problem.

    I simply can not believe, 2 years on that Apple has not corrected this issue. And believe me, I know what I’m talking about when I say Apple are the one’s at fault here.

    Is great to see that you’ve arrived at a workable work-around for yourself Murphy, but I simply don’t email photos enough to consider anything other than a fix as a viable ‘solution’ here.

    With both the resources at Apple’s disposable, the inflated prices we pay for their hardware, and the sheer number of people using their products, this has to be fixed.

  4. Excellent post! We are linking to this great post on our
    site. Keep up the good writing.

  5. Nice post. I learn something totally new and
    challenging on sites I stumbleupon every day. It will always be interesting to read through articles from other authors and practice something from other sites.

  6. hehe I see that you and Kaleb have duling neibwe guides for script automators. While I enjoyed Autohotkey for windows I also enjoyed the ease of Automator. I used it to select files from a folder, copy them to a new folder and then zip them. It took a little to learn how to do it, but in the end it was well worth the time.

Leave a comment