• Edit
  • Delete

Imagemagick Nconvert Photos Images

http://www.imagemagick.org/Usage/

Mass resize

jpg to useful size:

mogrify -verbose -format jpg -auto-orient -resize 2048x2048 -compress JPEG -quality 90 *.jpg

resize jpgs while recursing into subdirectories

find . -name "*.jpg" | xargs mogrify -verbose -format jpg -auto-orient -resize 66% -compress JPEG -quality 90

If you want to restory the file modification date afterwards:

exiftool '-FileModifyDate<DateTimeOriginal' -r -v -ext jpg .

other stuff:

mogrify -path small -auto-orient -sample 860x574 -compress JPEG -quality 80 *.*

mogrify -format jpg -auto-orient -strip -compress JPEG -quality 80 *.*

mogrify -format png -auto-orient -strip -resize 64x64 *.png

resize gives better quality than sample, but is slower

Make background color transparent

Simple color replacement

convert input.png -transparent white output.png

Pretty good, flood fill with fuzz percentage

convert input.png -bordercolor white -border 1x1 -alpha set -channel RGBA -fuzz 5% -fill none -floodfill +0+0 white -shave 1x1 output.png

For multiple images

mogrify -path modified_images -format png -bordercolor white -border 1x1 -alpha set -channel RGBA -fuzz 5% -fill none -floodfill +0+0 white -shave 1x1 *.jpg

Useful Addition: -trim to remove unnecessary border

Strip color profile information

mogrify -format png -strip *.png