How to convert Png to Jpg images on Ubuntu, via command line (Terminal commands). Use ImageMagick Convert command to convert PNG to JPG images on Ubuntu. Resize images on Ubuntu via command line (Terminal).
The convert program is a member of the ImageMagick suite of tools. Use it to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.
- SYNOPSIS
convert [input-option] input-file [output-option] output-file
Use any setting or operator as an output-option. Only a limited number of setting are input-option. They include: -antialias, -caption, -density, -define, -encoding, -font, -pointsize, -size, and -texture as well as any of the miscellaneous options. By default, the image format of `file’ is determined by its magic number. To specify a particular image format, precede the filename with an image format name and a colon (i.e. ps:image) or specify the image type as the filename suffix (i.e. image.ps). Specify ‘file’ as ‘-‘ for standard input or output.
How To Use Convert Command
To use the convert command, you must have installed ImageMagick app on your system. If not, run the following commands to install ImageMagick software on Ubuntu Systems.
Once installed, you can use the convert command to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. See below for example usages of the command.
To get started, lets convert an image in the JPEG format to PNG. For this tutorial, we are using image file named Cake.PNG.
To convert Cake.PNG to Cake.JPEG (Cake.JPG):
convert cake.jpg cake.png
To convert Cake.JPG to Cake.PNG:
convert cake.png cake.jpg
The convert command can also be used with more than 100 command options or parameters. Using the convert command you can resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. Let us see some examples:
Reduce the image size before it is converted to the PNG format:
convert cake.jpg -resize 50% cake.png
You can combine multiple image-processing operations to produce complex results with improved quality.
Convert an image with a specific/fixed height and width in pixels. You can also use the convert command to convert the image to a specific width or height.
Convert an image to 400 pixels in width and 200 pixels in height:
convert cake.png -resize 400×200 cake.png
Resize Cake.PNG image to a width of 400 pixels:
convert cake.png -resize 400 cake.png
Resize Cake.PNG image to a height of 200 pixels:
convert cake.png -resize x200 cake.png
By default, the convert command will preserve the aspect ratio of the image. Using the additional parameters, the aspect ratio settings can also be changed.