Skip to content

Instantly share code, notes, and snippets.

@Postrediori
Last active September 26, 2024 08:10
Show Gist options
  • Save Postrediori/c68d63d4b3e1d08a3151f5614a35ba06 to your computer and use it in GitHub Desktop.
Save Postrediori/c68d63d4b3e1d08a3151f5614a35ba06 to your computer and use it in GitHub Desktop.

ImageMagick HowTo

Resize and crop image

convert input.jpg -resize 100x100^ \
                  -gravity Center  \
                  -crop 100x100+0+0 +repage  \
        output.jpg

Cycle Hue

for i in $( seq 0 100 ); do
  output_file=$( printf "frame%04d.jpg" ${i} )
  convert input.jpg -modulate 100,100,$i ${output_file}
done

Batch Convert Images Into Another Format

Use mogrify:

mogrify -format png *.svg

Old-school method:

Linux (bash):

for f in $(ls *.png); do convert $f "$(basename -s .png $f).jpg"; done

Windows (cmd):

for /r %%f in (.\*.heic) do (
  echo "fullname: %%f"
  echo "name: %%~nf"
  convert "%%f" "%%~nf.jpg"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment