•
I had a solution, but now it’s broken. Before we get into that let’s review what we’re talking about.
If you email portrait (vertically) – oriented photos from your iPhone your recipient is likely to view them sideways, especially if they open them using a browser-based mail service like Gmail.
The solution I was actually using: Email the files to myself first. My Mac would receive the photos and run an AppleScript triggered by the email subject. The script rotated the files, stripped out the exif tag that caused the problem, and mailed them back to me. I could then use that copy for sending to other people. It was relatively painless as I could email the photo right from the Camera app which kept the number of steps reasonable.
But a couple things aren’t working with Lion. The part of my AppleScript that pulls the attachments out and saves them to a folder in the Finder isn’t working. Others have the same problem. Further, the Automator action that sent the email back out isn’t working either. I’m not alone on that one either.
So, I looked at alternate solutions. Like uploading to Dropbox. Dropbox uploads a full res version of your photo. So I created a folder action script that handles the rotating and exif tweaking as soon as my Mac sees the file. That works fine. The problem is that the Dropbox app on my iPhone doesn’t download the full res version, it pulls down a version I consider too small.
I didn’t give up right away. The iOS Safari Dropbox DOES open a nice big version of the photo. From there I can save the photo to my camera roll and email it out. Recipients get a correctly oriented version of the photo, big enough to see.
So now the problem is the number of steps and apps involved. I could use something like Instagram but sometimes I just want to send a photo in an email, straight-up.
I don’t understand why Apple has made this an issue. iOS used to rotate a different way. Their own browser on the Mac isn’t going to display the photo correctly because of the way they’re handling the rotation, with a tag. Why browsers can’t read the tag – I don’t know.
Anyway, I’ve got a solution for when I need it, but I don’t see myself using it much. Too many steps.
11/2011 Update: I have this working again. My Automator workflow fails at the step where it sends the email. So I’ve updated the AppleScript with a command to send it. I’ll post the updated script shortly.
|
Permalink
•
Ever want to hide ALL your applications and start with a clear, swept off desktop on your Mac? Yeah, there’s Exposé, but that’s not the same as what we’ll see here. When you show your desktop via Exposé you’re not changing the state of your applications to hidden – so as soon as you switch to an application the others will all be visible too.
If you’ve used Windows you may have used the Show Desktop icon in the taskbar to minimize all windows. We’re not going to minimize, we’re going to hide. But the end effect is the same. You’re looking at your desktop with nothing in your way.
How do we do this? A very short and simple Applescript. With one small concession.
If you’ve ever tried to hide ALL your applications you probably know what our obstacle is.
Try this: Switch to Finder and hit Command-Option-H. That hides all applications except Finder. Once they're hidden try hitting Command-H to hide the Finder itself. It doesn't work.
So here’s a workaround that’s acceptable to me: Our Applescript will hide the windows of all applications except the Finder. Then it will CLOSE all the Finder windows. The end result is a clean desktop with application windows that stay out of sight until you summon them back into view.
Optionally, you could include the 3 lines of the script after the line “Close every window” (commented out with dashes in the image below) to open up a single Finder window to a specified folder and use that as your starting point.

Once you’ve created the script you need a way to kick it off. I use TextExpander for a lot of these things. TexExpander is a fantastic text replacement utility that can also run Applescripts when you type certain characters. For example, Murphy might type dsktp or ddesk to make TextExpander run our script and display the clean desktop. There’s a lot more to TextExpander than running Applescripts, but I find it very handy in that capacity. Instead of memorizing somewhat arbitrary key combinations you can make up a code – so your shortcuts are more like keywords with meaning than shortcuts that generally only carry one letter. Murphy covered TexExpander here.
As an alternate check out FastScripts from Red Sweater Software. FastScripts lets you assign a script to a keyboard shortcut. And it has powerful features for helping you manage your script library. If you’re a heavy Applescripter you probably already know about it. If not, take a look at the features.
|
Permalink
•
“I don’t think necessity is the mother of invention. Invention, in my opinion, arises directly from idleness, possibly laziness, to save myself trouble.”
-Agatha Christie
In Murphy’s continuing efforts to avoid leaving the sofa he’s using an iPhone to kick off Spotify on the Mac upstairs and have it stream over Airfoil to an Apple TV connected to a stereo downstairs. It works, it’s pretty simple, and once it’s started there are other options for controlling it. 
The key is that Spotify recently added some basic AppleScript support to their Mac app. Not as much as we’d like to see, but enough to get us started. Spotify says they’re just experimenting with AppleScript at this point. (There were workarounds before Spotify added support) We’ll be watching for further enhancements.
This short and simple AppleScript (view entire script) is all you need to get started. It launches Airfoil (an application for redirecting audio from your Mac to remote speakers via Airport Express or Apple TV) and selects Spotify as the audio source application. Then it selects a playlist in Spotify and initiates playback. That’s it. Let’s take a look at the script.

The lines in the first block set Spotify as the application Airfoil will pull audio from. As long as you’ve got Spotify in your Applications folder you can copy those lines exactly. The line in the next block references your speaker id, which you probably don’t know. You can get the id by running a very simple script that looks like this. That line will query your remote speaker for its id and display it in the results pane of the Applescript Editor. Be sure to use the name of your Apple TV or Airport Express in the quotes. Once you’ve got the id you shouldn’t need to run that script again.

The script pauses to make sure your Mac doesn’t get ahead of the launching applications. Spotify hasn’t provided playlist selection hooks for Applescript yet, but they do provide something almost as good. In the Spotify application you can right-click a playlist or track and get an identifier, just like you see in the screenshot at the top of the post. You want to select Copy Spotify URI. Notice the open location line in the script, it’s not inside the Spotify tell – end tell section because it’s not in the Spotify Applescript dictionary. Regardless, it works to select a playlist and that’s all we really need. The last part of the script tells Spotify to start playing.
So – now we just need the script to run. Murphy is using a Mail rule. He sends himself an email with a subject Mail is watching for. Mail runs the script whenever a message with that subject comes in. Once Spotify is up and running the Speakers app that comes with Airfoil can be used to pause or skip to the next track.
I’d rather have an application on my iPhone, maybe something like TextExpander, that could list Applescript TextExpander snippets on my Mac and kick them off that way. But I don’t know of an app like that. The email kick-off works fine, and it’s quick and easy to use, but at times I might have to use another app to wake the Mac up.
In the past I’ve used Mail to run Applescripts on my Mac. It started with putting my Mac to sleep by email but I’ve also used the strategy for kicking off iTunes (before the Remote app) and for file retrieval.
If you’re looking for more information on Applescript and Airfoil they’ve got some examples on their site.
Interesting: Initially I made a script that opened a Spotify playlist and didn’t include the line to commence playback. It stopped working after a day, I don’t know why. It would play the one track and then stop. The day before it jumped to whatever playlist had been set as the current playlist in the Spotify application and continued playback. Not sure what happened there.
|
Permalink
•
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 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
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:
/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
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.
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.
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
•
Note: This was posted before Airplay. But it still applies to the old Apple TV.
I was thinking it would be nice to watch a video I’d just recorded with my iPhone on the Apple TV. But it’s kind of a pain to do that. I’d have to run the iPhone upstairs, plug it in, wait for it to sync, add the video to a playlist…
Alternative: I could upload the video to YouTube, but you have to fill out the fields to upload and it seems sometimes my Apple TV loses track of my YouTube account. Or at least loses access.
So I’ve got a Rube Goldberg alternative that makes it really simple from a user perspective – once you’ve done the upfront legwork. Just email the video to yourself, if it’s short enough. Let your Mac automatically grab the video from your email and drop it into iTunes. My Apple TV seems to immediately sync on its own when new content is added to a Playlist that’s set to sync.
I’m using a pretty straightforward AppleScript and a rule configured in my Mac’s Mail program. Here’s what happens:
- I email the video to myself with the subject atv.
- The email arrives.
- A Mail-based rule sees the subject and kicks off an AppleScript that copies the video file to the Automatically Add to iTunes folder in my iTunes Music folder.
- The video gets added to my iTunes Library.
- The video is added to a Smart Playlist.
- The Apple TV is set to sync with the Smart Playlist.
- The video is synced to my Apple TV.
That looks like a lot of stuff but the Mac will do all the work. There are only a couple things you need to set up:
- Create a Smart Playlist and tell Apple TV to sync with it
- Create a rule in mail and have it run the AppleScript when a matching email comes in.
Then all you do is email yourself the video. If you open Finder and look around in your iTunes Music folder you’ll see a folder called Automatically Add to iTunes. Anything that gets dropped in there gets added to your library, so that’s where the script copies the file.
I threw this script together quickly, there’s nothing fancy, no error checking – so feel free to post any enhancements. My intention is to provide an example of what can be done easily with AppleScript and Mail rules. It might help someone accomplish other tasks similar to this one.
Here’s a link to the script and screenshots of a Mail rule and sample Smart Playlist settings. The script was saved as a text file. You need to change the path in the third line of script to reflect your user name. You also need to save it as an AppleScript using AppleScript Editor.
In the Mail rule you need to change the path to where you saved your AppleScript.
Mail Rule Screenshot:

Smart Playlist Screenshot:

You might come up with something more sophisticated for the Smart Playlist…
Finally – here’s a look at the AppleScript, which you can download.

Other tricks with Mail: Pick a Playlist by Email – Retrieve a File by Email – Mail a File Dropped in a Finder Folder
|
Permalink