Archive

Posts Tagged ‘convert’

Batch image cropping

January 25th, 2010 MiB 3 comments

Today I decided to prepare new gallery for Behemoth`s Lair Heroes 3 service. The very first step I have to take was to thumbnail existing images that each will fit exactly 100 x 100 dimensions and keep it`s original ratio. With PHP I would use IMagick::cropThumbnail() which do exactly what I need. IMagick uses Image Magic and so do I :) Beneth you will find results of my research: this code will create thumbnails for all JPG images from current directory and save them into thumb subdirectory.

find . -maxdepth 1 -iname '*jpg' -exec convert {} -thumbnail 100x100^ -gravity Center -crop 100x100-0-0 thumb/{} \;