Convert Images in Terminal on a Mac

There is some wanky muss with my Piwigo install so I’ve been playing around with all sorts of things. One thing I found is that it no longer seems to like “.png” files as “pwg_representative” for video files. Okay fine, but seriously why all of a sudden? But I digress.. The built-in “sips” (Scriptable Image Processing System) command on a Mac is an easy way to convert a bunch of images from png to jpg. This also works with other formats by the way.

sips -s format jpeg My_Picture.png –out My_Picture.jpg

An oddity for sure is that after “format” you need “jpeg” not “jpg” and yet if you specify “My_Picture.jpeg” it will warn you that it changed your file name to “My_Picture.jpg”. Way to go Apple. Anyway its a useful command, as the name suggests, its good for scripting. Here is how I scripted it..

for PICTURE in `ls pwg_representative | grep png`; do sips -s format jpeg pwg_representative/$PICTURE –out pwg_jpg/`echo $PICTURE | sed ‘s/.png/.jpg/’`; done

Feel free to suggest a more elegant way to do it.