How to reduce image size in Linux command line without losing quality. On Ubuntu, users can reduce image file size via command line using convert command.
Installing ImageMagick
Run the following commands in terminal to install ImageMagick on Ubuntu via Appimage:
$ wget https://download.imagemagick.org/ImageMagick/download/binaries/magick $ chmod +x magick $ sudo mv magick /usr/bin/ $ ./magick
Using Convert Command
The convert command can convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.
The convert program is a member of the ImageMagick suite of tools. The command can be use used to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.
Using Convert Command
Syntax of the convert command is:
convert [input-option] input-file [output-option] output-file
If you wish to resize an image named Image1 to Image2 with a file esolution of 1200×1000, run the following command:
convert -resize 1200x1000 Image1.jpg Image2.jpg
Similarly you can also reduce the image size by percentage. For example if you wish to resize rose.jpg by 50% and create a new file with rose.png, run the following command:
magick rose.jpg -resize 50% rose.png
NOTE: The above command will convert the image file in the JPEG format to PNG.
You can read more about the command here.