Skip to content

Instantly share code, notes, and snippets.

@agermanidis
Last active May 30, 2021 21:57
Show Gist options
  • Save agermanidis/b32f6ccca037ee3b066bbffd09037f4e to your computer and use it in GitHub Desktop.
Save agermanidis/b32f6ccca037ee3b066bbffd09037f4e to your computer and use it in GitHub Desktop.
bash script to resize an image to multiple sizes with one command using ImageMagick
#!/bin/bash
# Usage: ./resize_many.sh <filename> <sizes...>
# e.g. ./resize_many.sh myasset.png 10x10 20x20 30x30
# produces 3 files, myasset10x10.png myasset20x20.png myasset30x30.png
fullname=$1
shift;
sizes=$*
extension="${fullname##*.}"
filename="${fullname%.*}"
for size in $*
do
convert $fullname -resize $size $filename$size.$extension
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment