Howto: Linux convert an image between different formats from command prompt

September 8, 2019

Rate this post

Q. How do I convert images from a shell prompt? For example convert an image in the JPEG format to PNG or vise versa?

A. You need to use the convert command which is a member of the ImageMagick suite of tools. Use it to convert between image formats as well as
=> Resize an image
=> Blur an image
=> Crop an image
=> Despeckle an image
=> Dither an image
=> Draw on an image
=> Flip an image
=> Join an image
=> Re-sample, and much more.

Task: Convert an image in the JPEG format to PNG

Type the command as follows:
$ convert input.jpg output.png

Task: Resize the image

Resize and convert an image in the JPEG format to PNG
$ convert -resize 50% input.jpg output.png

You can also create a complex effect such as:
$ convert -size 360x85 xc:transparent -font Bookman-DemiItalic -pointsize 72 -draw "text 25,60 'SXI LLC'" -channel RGBA -gaussian 0x6 -fill YellowGreen -stroke RosyBrown -draw "text 20,55 'SXI LLC'" SXI LLC.png


Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.