imagemagick for bulk image editing


Install imagemagick on ubuntu

sudo apt update
sudo apt install imagemagick -y

Display image with imagemagick

display filename.png

Get image file info

identify -verbose filename.png

Crop image from top

Take image width*height+right+top. The following command will crop the image from the top by 140px.

mogrify -crop 150x300+0+140 sea.jpg

Bulk Image crop with imagemagick by file type

All the .jpg images will be cropped by 140px from the top.

mogrify -crop 150x300+0+140 *.jpg

Convert images from png to jpg in bulk

This comand will convert all the images in the folder from png to jpg format

mogrigy -format jpg *.png

Resize images in bulk by format type

The following command will half the image width and height by 50% of all jpg images in the current folder and keep 100% picture quality.

mogrify -adaptive-resize 50% -quality 100% *.jpg
mogrify -resize 115X115 -quality 100% *.png
mogrify -resize 115X115 -quality 100% *.jpg

Flip-Flop images with imagemagick

mogrify -flip filename.png
mogrify -flop filename.png

Generate Image file

convert -size 1920x1080 canvas:darkblue out.png

Put text on image with imagemagick

convert -font helvetica -fill white -pointsize 150 -gravity center -draw "text 0,50 'INSTALL WORDPRESS'" input.png output.png
convert -font helvetica -fill yellow -pointsize 150 -gravity center -draw "text 0,220 'ON LINUXMINT'" output.png output1.png 

Pixlate Image with imagemagick

This also increases the output image size that you can resize down to your original image with -resize flag.

convert -scale 10% -scale 1000% input.png output.png