Showing posts with label Imagemagick. Show all posts
Showing posts with label Imagemagick. Show all posts

Monday, September 29, 2014

Imagemagick annotate and animate

Anotate an image:

$convert in.jpg -fill white -pointsize 20  -annotate +20+30 'Blahblah' out.jpg

Make a looping gif of all jpg images in the current folder with 50 ms delay between frames:

$convert   -delay 50   -loop 0  *.jpg  my.gif


Wednesday, June 5, 2013

ImageMagick Cheat Sheet

# negate
$ convert black-white.png -negate white-black.png

# rotate
$ convert upside-down.png -rotate 180 rightside-up.png

# resize
$ convert img.gif -resize 64x64 resized_img.gif

#convert to grayscale 
$ convert -type Grayscale color.jpg gray.jpg

# find the differences between two images
$ composite img1.jpg img2.jpg -compose difference diff.jpg

# compare images using a metric (can be mse, psnr and more)
$ compare -verbose -metric mse 1.jpg 2.jpg difference.png

# compose two images together using a mask (stencil)
$ convert -size 512x256 tile:img.jpg  tile:img2.jpg mask.jpg -composite result.jpg



Monday, April 8, 2013

Make an image montage using ImageMagick

The following makes a 1x10 vertical montage of all .png images in the current folder. Before adding to the montage, images are cropped.

$ montage -geometry +0+0 -tile 1x10  -crop 170x70+115+125 *png montage.jpg

-geometry controls the border arround each sub-image in the montage. +0+0 means no border.

How to decode the crop string "170x70+115+125" :

170x70: new size of the cropped image
+115+125: Pixel (0,0) of the cropped image will be pixel (115,125) of the old one. Pixel (170,70) of the cropped image is pixel (170+115, 70+125) of the old one.