Created
July 4, 2013 03:48
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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