iPhone Photo Rotation – Part TwoShare
Murphy 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 your home folder create a folder called lab with subfolders in and out. Like this:
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.
Create 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:
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.
In 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.
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.
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.
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.
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.
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