How to manipulate images from the terminal

ImageMagick is an application that allows us to manipulate images through the command line and that is used for practically all formats. With it, it is also possible to automate the actions on the images contained in a folder (conversion, resizing, etc ...)
Let's see a list of useful ImageMagick commands:

Get information from an image.

identify -ping image.png

Get even more information.

identify -verbose image.png

Know the list of colors used in an image.

identify -list color image.png

Convert a PNG image to JPG

convert image.png image.jpg

Convert a PNG image to JPG indicating the conversion quality.

convert -quality 96 image.png image.jpg

Convert all PNG images to JPG contained in a folder

mogrify -format png *.jpg

Convert all images (* .jpg, * .png) to PDF

convert images*.* archivo.pdf

Resize an image

convert -resize 48×48 image.png image-mini.png

Resize all images in a folder

mogrify -resize 48×48 *.png

Resize an image by specifying the width

convert -resize 620x image.png image-620.png

Resize an image by specifying its height

convert -resize x100 image.png image-100.png

Create a Favicon

convert -colors 256 -resize 16×16 image.jpg favicon.ico

Convert a color image to black and white

convert -type image.jpg image-noir-blanc.jpg

Add a 1 pixel transparent border around an image

convert -bordercolor Transparent -border 1×1 image.png image-borde.png

Add a 10 pixel black border around an image

convert -bordercolor #000000 -border 10×10 image.png image-borde.png

Create a negative of an image

convert -negate image.png image-negate.png

Rotate an image vertically

convert -flip image.png image-inversee.png

Rotate an image from left to right

convert -flop image.png image-inversee.png

Use the ImageMagick GUI

display image.png


Add as preferred source in Google