Created
April 19, 2018 10:36
-
-
Save paleite/000ea91a78bac6f3e4bdc87dd4e846aa to your computer and use it in GitHub Desktop.
Batch resize and convert images with retina-support
This file contains hidden or 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 | |
if ! brew ls --versions imagemagick > /dev/null; then | |
# The package is not installed | |
echo "Installing imagemagick…" | |
brew install imagemagick | |
fi | |
echo "Resizing to @2x…" | |
mogrify -path . -resize "160x30>" ../originals/*.png | |
ORIGINALS=`find . -name "*.png" \! -name "*@2x.png"` | |
for original_filename in $ORIGINALS | |
do | |
retina_filename="${original_filename%.png}@2x.png" | |
mv $original_filename $retina_filename | |
done | |
echo "Resizing to @1x…" | |
mogrify -path . -resize "80x15>" ../originals/*.png | |
echo "Optimizing…" | |
imageOptim --image-alpha --skip-if-larger --quit --verbose --directory . | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment