Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Created March 4, 2011 23:45
Show Gist options
  • Save ttscoff/855922 to your computer and use it in GitHub Desktop.
Save ttscoff/855922 to your computer and use it in GitHub Desktop.
Rough Bash script for pulling icon files from Mac applications
#!/bin/bash
APP=`echo $1|sed -e 's/\.app$//'`
# Removes ".app" if it was passed
ICON=`defaults read /Applications/$APP.app/Contents/Info CFBundleIconFile|sed -e 's/\.icns$//'`
# Removes ".icns" if the Info.plist has it
# Harcoded for /Applications, needs to be rewritten for other locations or droplets
## Save icon on Desktop in JPEG format, resized to 256 max width/height
OUTFILE="$HOME/Desktop/${APP}_icon.jpg"
sips -s format jpeg --resampleHeightWidthMax 256 "/Applications/$APP.app/Contents/Resources/$ICON.icns" --out $OUTFILE
# Open in ImageOptim for better compression ( http://imageoptim.pornel.net/ )
open -a "ImageOptim.app" $OUTFILE
### OR ###
## Output file to a temp directory as a PNG and open in Skitch for resizing and conversion
# OUTFILE="$TMPDIR${APP}_icon.png"
# sips -s format png "/Applications/$APP.app/Contents/Resources/$ICON.icns" --out $OUTFILE
# open -a "Skitch.app" $OUTFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment