Compress images on Linux (ubuntu)

Image resizing/compression for linux

 ImageMagick isn’t included in the default installations of Ubuntu and many other Linux distributions. To install it on Ubuntu, use the following command:

    sudo apt-get install imagemagick

Converting Between Formats
convert a.png b.jpg

You can also specify a compression level for JPEG images:

convert a.png -quality 95 b.jpg
Resizing Images

The convert command can also quickly resize an image.
Here you can asks ImageMagick to resize an image to 100 pixels in width and 50 pixels in height:

    convert a.jpg -resize 100×50 b.jpg

  Reduce size of  all images with same name (No name change after reducing)

 for fileName in *.jpg; do convert $fileName -quality 50 $fileName; done

 Rotating an Image

ImageMagick can quickly rotate an image. The following command takes an image named howtogeek.jpg, rotates it by 90 degrees and saves the rotated image as howtogeek-rotated.jpg:

 convert a.jpg -rotate 90 b.jpg

If you failed to install it like below...

  Unable to fetch some archives, maybe run apt-get update or try with --fix-missing
Then go for this...

sudo apt-get update

sudo apt-get install imagemagick --fix-missing 

For more Info please go:


Popular posts from this blog

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Struts 2 - struts tag with boolean property