Skip to content

Instantly share code, notes, and snippets.

@szhu
Last active December 1, 2022 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szhu/a08a496f244163597a41204042d8fe09 to your computer and use it in GitHub Desktop.
Save szhu/a08a496f244163597a41204042d8fe09 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Add thumbnails to images. This works well for document images (like PDFs),
# where the top of the image is the most important.
for file in "$@"; do
# `--cropOffset 0 0` doesn't do anything, so we use a small offset.
sips \
-s format png \
--resampleWidth 512 \
--cropOffset 0 0.001 \
--cropToHeightWidth 512 512 \
"$file" \
--out "_tmpThumbnail.png" \
>/dev/null
fileicon set "$file" "_tmpThumbnail.png"
rm _tmpThumbnail.png
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment