Notes about ImageMagick
From IdeaNet
Jump to navigationJump to search
- conversion from multiple images to compressed PDF in A4 format
convert -format A4 -compress <compression> -adjoin *.jpg output.pdf
where:
- <compression> = Zip or Group4
- conversion from image to PDF with rotation
convert -rotate <degrees> input.jpg output.pdf
- conversion from image to PDF with defined print area
convert -units PixelsPerInch -density <density> -geometry <geometry> -adjoin input.jpg output.pdf
where:
- <geometry> = the resolution required for the pdf file
- <density> = value in dot/inch
- Will define the print area. To get a PDF printable on A4 format (21cmx29.7cm), density should be calculated with respect to -geometry option
- E.g.: -geometry 2048x1280
- => density(width) = 2048pixel / 21cm * 2.54cm/inch = 248 pixel/inch
- => density(height) = 1280pixel / 29.7cm * 2.54cm/inch = 109 pixel/inch
- => The resulting command will be:
convert -units PixelsPerInch -density 248x109 -geometry 2048x1280 input.jpg output.pdf
note: you don't need to multiply by 2.54cm/inch when using -units PixelsPerCentimeter
- to get information from an image file
identify -verbose img.jpg
- create one image composed from 4 images
montage -frame 5 -geometry +0+0 img1.png img2.png img3.png img4.png result.png
- Result will be:
------------- | img1 | img2 | ------------- | img3 | img4 | -------------
montage -tile 3x2 -frame 5 -geometry +0+0 img1.png img2.png img3.png img4.png result.png
- Result will be:
-------------------- | img1 | img2 | img3 | -------------------- | img4 | | --------------------
- More about
montage
command: http://www.imagemagick.org/Usage/montage/
- crop image
convert -crop WxH+Wo+Ho +repage source.jpg destination.jpg
with:
- W: width of cropped image
- H: height of cropped image
- Wo: width offset from upper/left corner of source.jpg
- Ho: height offset from upper/left corner of source.jpg
- More about
crop
command: http://www.imagemagick.org/Usage/crop/