Last active
October 19, 2016 09:58
-
-
Save julesjans/00f4197defe8e404f0a44ea25a6871ca to your computer and use it in GitHub Desktop.
Takes an icon PNG as an argument, uses sips (macOS) or convert (ImageMagick), makes a lot of icons!
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 | |
# Takes an icon PNG as an argument, uses sips (macOS) or convert (ImageMagick), makes a lot of icons! | |
input_file=$1 | |
sizes=(20 29 40 50 57 60 72 76 83.5 512) | |
scales=(1 2 3) | |
for size in "${sizes[@]}" | |
do | |
for scale in "${scales[@]}" | |
do | |
output_size=$(echo "${size}*${scale}" | bc -l) | |
output_file="$(dirname "$input_file")/${size}@${scale}x.png" | |
if command -v sips >/dev/null 2>&1; then | |
sips --resampleWidth ${output_size} "${input_file}" --out $output_file | |
elif command -v convert >/dev/null 2>&1; then | |
convert -resize x${output_size} "${input_file}" $output_file | |
else | |
echo "No suitable image library found to create: $output_file" | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment