How To Batch Letterbox Images with Imagemagick

From steamWiki
Revision as of 08:15, 31 January 2022 by Sean (talk | contribs) (Created page with "=Letterboxing= To be able to run the command below you'll need to install a utility called [https://imagemagick.org/index.php ImageMagick]. This command will take an input ima...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Letterboxing

To be able to run the command below you'll need to install a utility called ImageMagick. This command will take an input image and letterbox it into a 4:3 aspect ratio with black borders

magick INPUT.JPG -set option:wd "%[fx:(4/3)>(w/h)?(4/3*h):w]" -set option:ht "%[fx:(4/3)>(w/h)?h:(w/(4/3))]" -gravity center -background black -extent "%[wd]x%[ht]" OUTPUT.JPG

Batch Letterboxing at the Windows Command Line

This command will letterbox all JPG files in the active directory into 4:3 aspect ratio images with black borders

for %i in (*.jpg) do magick %i -set option:wd "%[fx:(4/3)>(w/h)?(4/3*h):w]" -set option:ht "%[fx:(4/3)>(w/h)?h:(w/(4/3))]" -gravity center -background black -extent "%[wd]x%[ht]" %i

References