Darkland | net

ImageMagick Notes

Published on 11 January, 2018 by amj
Updated - 14 September, 2020 -- amj

Error message: convert-im6.q16: cache resources exhausted
Edit /etc/ImageMagick-6/policy.xml:
Change
<policy domain="resource" name="area" value="128MB"/>
to
<policy domain="resource" name="area" value="1GiB"/>
And
<policy domain="resource" name="disk" value="1GiB"/>
to
<policy domain="resource" name="disk" value="16GiB"/>
Reference:https://stackoverflow.com/a/53699200

Resize multiple image files in a directory to specific dimensions using find: find ./ -maxdepth 1 -type f -exec convert -scale 1280x960 {} {} \; -maxdepth limits find to the current directory and prevents it from descending in to any subdirectories.

Remove metadata from image file: convert -strip [target] [destination]
Create a new image with a border and caption: convert ./20200621\ -\ Priscila\ Benicio.jpg -type TrueColor -resize 90% -bordercolor Black -border 5% -pointsize 32 -fill "#6699ff" -draw "text 410,40 '\"Move Yourself ♥👊\"'" -draw "text 315,1050 '21.06.2020 - Priscila Benicio'" ./20200621\ -\ Priscila-001.jpg-resize 90% resizes image to 90% of original image size, and not by 90%.

Create a contact sheet--montage calls this a composite image--from multiple jpegs or pngs in a directory:
Example 1: montage -verbose -label %f -tile 5x4 -background "#000000" -fill "white" -define jpeg:size=240x180 -geometry 240x180 -auto-orient ./*.jpg -title "Dana Scully Has Never Been A Vegan" contact.jpg Example 2: montage -verbose -tile 2x2 -background "#000000" -border 2 -bordercolor "black" -define jpeg:size=640x480 -geometry 640x480 -auto-orient ./*.jpg ./contact.jpg
These examples operate on jpegs, but any image file extension can be used. Be careful if operating on animated gifs. montage will dissasemble them and create a contact sheet of individual frames.

Also, any transparent pixels in an animated gif will be converted to the defined background color for the contact sheet. The animated gif must be converted from an "overlay animation" into a "coalesced animation" to prevent this.
Reference:https://stackoverflow.com/questions/13317825/imagemagick-leaves-artifacts-in-gif-to-jpg-list-conversion#13317877
Back