Skip to content

Instantly share code, notes, and snippets.

@Lerg
Created June 2, 2014 19:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Lerg/02e228b0f5423bbaf1dc to your computer and use it in GitHub Desktop.
Save Lerg/02e228b0f5423bbaf1dc to your computer and use it in GitHub Desktop.
Automatically downsizes your @4x and @2x images in the current directory
#!/bin/sh
ext=$1
for f in $(find . -name "*@4x.$ext"); do
echo "Converting $f..."
convert "$f" -resize '50%' -unsharp 1x4 "$(dirname $f)/$(basename -s "@4x.$ext" $f)@2x.$ext"
done
for f in $(find . -name "*@2x.$ext"); do
echo "Converting $f..."
convert "$f" -resize '50%' -unsharp 1x4 "$(dirname $f)/$(basename -s "@2x.$ext" $f).$ext"
done
@Lerg
Copy link
Author

Lerg commented Jun 2, 2014

Usage:
./downsize.sh jpg
./downsize.sh png

@Lerg
Copy link
Author

Lerg commented Jun 2, 2014

You need to install ImageMagick for this to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment