Mimsy Were the Borogoves

Hacks: Articles about programming in Python, Perl, Swift, BASIC, and whatever else I happen to feel like hacking at.

Copying album art with GraphicConverter

Jerry Stratton, May 11, 2012

I have not owned a scanner, ever. Back when it would have been useful, I couldn’t afford one, and now that I can afford one, most everything is already digital. The one place where a scanner would be useful is copying album art from vinyl for iTunes.

What I’ve ended up doing is taking a digital photo of the album and—at first—trying very hard to take it so that the album cover was square enough for cropping. Once I discovered GraphicConverter’s Unskew1 function, squaring album covers became a lot easier. Unskew lets me specify the four corners of the album cover so that GraphicConverter can square it for me. I no longer have to worry about taking a perfectly-oriented photo of each album.

Skewing With Disaster: GraphicConverter’s Unskew feature makes it easy to square up album covers.; GraphicConverter

Align the corners of the unskew box with the corners of the album, and GraphicConverter will unskew the album cover.

After I square the album cover, there are a series of steps that I always take. I autolevel the image, scale it to a standard width, copy it, and then close the window. This is, of course, a mini-workflow, and should be able to be automated.

[toggle code]

  • tell application "GraphicConverter"
    • tell window 1
      • --manually make sure tolerance is .2%
      • autolevel
      • --scale to 800 pixels wide
      • set imageRect to image dimension
      • set width to the first item of imageRect
      • set scaleFactor to 800 / width
      • scale horizontal scaleFactor vertical scaleFactor
      • --select all and copy
      • set imageRect to image dimension
      • set width to the first item of imageRect
      • set height to the last item of imageRect
      • set selection to {0, 0, width, height}
      • copy
      • close without saving
    • end tell
  • end tell

The only problem with this script is that GraphicConverter doesn’t support including the desired tolerance with the autolevel command. I’ve found that .2 is a good choice for tolerance; I just have to make sure that whenever I change it for some other purpose, I always change it back to .2 before using this script.

The image dimension is a list of two numbers: the width and the height. Since I’ve decided that I want to standardize on 800 pixels wide, I get the first item from the image dimension, divide it into 800, and then scale the image both horizontally and vertically by that scale factor.

After autoleveling and scaling, I need to copy the image; the dimensions have changed, so I get the image dimension again, then set the selection to be the entire image: from 0 to width, and from 0 to height. Then, copy it and close it.

Now that it’s in the clipboard, I can go into iTunes and select whatever tracks it applies to and paste it in as album art.

You can store this script in the standard script folder if you have the “Script menu” enabled2, in ~/Library/Scripts/Applications/GraphicConverter/ as, for example, “Copy Album Cover”. You can also store it in GraphicConverter’s own scripts folder; as far as I can tell it works the same in either location.

  1. “Unskew (Set Proportions)…” under the “Effect” menu. Or Command-Control-E.

  2. Use AppleScript Editor’s General Preferences to “Show Script menu in menu bar”.

  1. <- Why I still use RSS
  2. Simple math pad ->