Note: Big difference between mogrify and magick/convert - mogrify rewrites the original image (and hence cannot add prefix or copy file) whereas convert âconvertsâ to a different file (hence can provide filename etc)
Converting between formats
-
png to pdf1
mogrify -quality 100 -density 200 -colorspace sRGB -flatten -format png *.pdf
-
jpg to png (requires background when png background is transparent)
convert output-file.png -background white -flatten output-file.jpg
Combining images
- Horizontally (into one row)
convert input-1.png input-2.png +append append_result.png
- Vertically (into one column)
convert input-1.png input-2.png -append append_result.png
Compressing jpgs
 mogrify -strip -interlace Plane -gaussian-blur 0.05 -quality 85% -adaptive-resize 50% *.jpg
Removed -sampling-factor 4:2:0
because it was messing with the color ratios for me. Blurring seemed to work well without any noticeable differences (at least to me).2
Inverting and colorizing images
convert image.jpg -negate negated-image.jpg
convert negated-image.jpg -colorize 0,50,0 colorized-image.jpg
For pngs, add -colorspace RGB
.34 I tried making a negative out of pngs but it did not work.
Manipulating Tiffs
Compressing TIFs into a jpg:5
mogrify -quality 80 -colorspace sRGB -flatten -format jpg ../*.TIF
Using one channel to make TIFs grayscale:6
mogrify -fx 'b' -quality 80 -colorspace Gray -flatten -format jpg ../*_uv.TIF
Adding watermark
magick input.png -gravity SouthEast -append -pointsize "%[fx:h*0.02]" -annotate +0+2 'watermark' output.png
pointsize (fontsize) can be a number or it can be relative. %[fx:h*0.02]
makes the pointsize 2% of the height of the image.7
Footnotes
-
https://stackoverflow.com/questions/7261855/recommendation-for-compressing-jpg-files-with-imagemagick â©
-
https://superuser.com/questions/636742/gimp-command-line-how-to-invert-color-of-a-list-of-picture-and-modify-the-color â©
-
https://stackoverflow.com/questions/40403424/selective-negative-image-with-imagemagick â©
-
https://stackoverflow.com/questions/68773121/combining-tiff-files-by-channel-with-imagemagick â©