IT Certificaions

Google Cloud Platform

Friday, October 5, 2012

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: https://help.ubuntu.com/community/ImageMagick