Skip to content

Instantly share code, notes, and snippets.

@ipetropolsky
Last active May 17, 2019 02:40
Show Gist options
  • Save ipetropolsky/7513122d4e7687523a9bd0fee3ae96d1 to your computer and use it in GitHub Desktop.
Save ipetropolsky/7513122d4e7687523a9bd0fee3ae96d1 to your computer and use it in GitHub Desktop.
Resize photos by imagemagick
size=50
mkdir converted
find . -type f -maxdepth 1 -print0 | \
xargs -0 -n 1 -P 8 -I __FILE__ \
convert __FILE__ -resize $size -set filename:new '%d/%t' \
\( -clone 0 -tile overlay.png -draw "color 0,0 reset" \) \
# -compose blend -define compose:args=50 \
-compose overlay \
-composite "converted/%[filename:new]_${size}.png"
rm -rf converted
mkdir converted
# Resize to width=16px
find . -type f -maxdepth 1 -print0 | \
xargs -0 -n 1 -P 8 -I __FILE__ \
convert -resize 16 -set filename:new '%d/%t' __FILE__ 'converted/%[filename:new]_16.png';
cd converted
rm -rf converted
mkdir converted
# Resize back to 130 with smoothing
find . -type f -maxdepth 1 -print0 | \
xargs -0 -n 1 -P 8 -I __FILE__ \
convert -resize 130 -set filename:new '%d/%t' __FILE__ 'converted/%[filename:new]_130.png';
# Resize back to 130 in pixels
find . -type f -maxdepth 1 -print0 | \
xargs -0 -n 1 -P 8 -I __FILE__ \
convert -resize 130 -filter Point -set filename:new '%d/%t' __FILE__ 'converted/%[filename:new]_130_pixels.png';
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment