karlherrick.com

ImageMagick Magic!

Thursday, 12 June 2008

I enjoy using ImageMagick… most of it has been via PHP CLI, however here we have a short example in Bash:

#!/usr/bin/env bash
for file in `ls -d *.png`; do
  convert -crop 1280X985+0+24 $file 
  $(basename $file .png).jpg;
done

Basically this does the following:

  • Makes a listing of all .png files in the current directory
  • Runs the “convert” command (part of ImageMagick) on each .png file in that listing
  • Crops the image specified by the geometry arguments
  • Saves the result as a .jpg


Home

About

Portfolio

Web Apps Web Enabled Applications Corporate Sites Personal Sites
Preferences Dark Theme Light Theme Notifications
Social GitHub LinkedIn RSS Feed Icon