Skip to content

imagemagick

install imagemagick, for example with brew:

brew install imagemagick

resize and keep aspect ratio

mogrify can also overwrite existing files and do edits inline

resize on width:

magick mogrify -geometry 256x *.png

resize on height:

magick mogrify -geometry x256 *.png

svg to png

use convert to create a png out of a svg file:

magick input.svg output.png

change the background color:

magick -background none input.svg -geometry 2400 output.png

the background color can be specified like so:

magick -background blue
magick -background "#ddddff"

png to svg

convert input.png output.svg

if you get an error like:

convert: delegate failed `'potrace' --svg --output

install potrace:

brew install potrace

and you should be good to go

webp to png

magick mogrify -format png filename.webp

animated webp to gif

magick mogrify -format gif filename.webp

source

image to c array

useful if you're going crazy with some cool e-paper/e-ink displays and an esp32.

magick img.bmp img.h

merge multiple images / screenshots

you can play around with the -tile option to position them next to each other ... like tiles you know.

montage -mode concatenate -tile 1x image-*.png out.jpg

merge them vertically:

magick input1.png input2.png +append output.png

or horizontally:

magick input1.png input2.png -append output.png

align them using gravity

if you have multiple sizes and you want them aligned in the center:

convert 1.png 2.png -gravity center -append great.png