Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Created July 4, 2013 03:48
Show Gist options
  • Save ttscoff/5924787 to your computer and use it in GitHub Desktop.
Save ttscoff/5924787 to your computer and use it in GitHub Desktop.
Create custom thumbnail icons from a file's Quick Look preview on OS X
#!/bin/bash
target=$1
filename=`basename $1`
image="${TMPDIR}${filename}.png"
rsrc="${TMPDIR}icn.rsrc"
# Create a thumbnail from the file preview
qlmanage -t -s 512 -o ${TMPDIR} $target
# apply the image to itself as an thumbnail icon
sips -i $image
# Extract the icon resource
DeRez -only icns $image > $rsrc
# Make the target accept a custom icon
SetFile -a C $target
# Apply the icon resource to the target
Rez -append $rsrc -o $target
# clean up
rm $rsrc $image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment