Thursday, February 3, 2011

Manipulate images with ImageMagick

Images can be easily manipulated from terminal with image magic package.  On ubuntu systems , imagemagick  can be installed as below.

 sudo apt-get install imagemagick  

Here are some tricks that I   use with imagemagick.

   1)  Create a thumb nail.

            $ convert screenshot.png   -resize 64x64  resized_sceenshot.png

          if you want to preserve the aspect ratio   put a !  after the size.

            $ convert screenshot.png   -resize 64x64\!  resized_sceenshot.png

      2) Add a border to an image 

             $ convert screenshot.png  -bordercolor SkyBlue    -border 10x10   screenshot_border.png      

    You can try different  colors and border size
     3)  Convert an image to black & white

          $ convert -type Grayscale screenshot.png  screenshot_bw.png

     4)  Add a label over the image.

           $ convert screenshot.png -gravity south  -stroke '#000C' -strokewidth 2 -annotate 0 ''  -stroke none  -fill white  -annotate 0 ''    screenshot_labelled.png
       5)  Generate labels from text
      $ convert -background lightblue -fill blue \
          -font Candice -pointsize 72 label:Unixlab \

Imagemagick offers lot of other possibilities . See  this site  for more examples. 


No comments: