Last Updated: February 25, 2016
·
701
· timpietrusky

Convert images with your shell

I needed a quick way to convert many images from jpg to png on Ubuntu and this is what I came up with.

1. Install Imagemagick (for Ubuntu)

sudo apt-get install imagemagick

You can find your system here.

2. Convert jpg to png and keep the original file name

convert *.jpg -set filename:original %t %[filename:original].png

This converts all the jpgs inside the current directory into pngs and keeps the original filename.

You can also set the -quality or convert from png to jpg or what ever you want.

You can also scale the image:

convert *.jpg -affine 0.5,0,0,0.5,0,0 -transform -set filename:original %t %[filename:original].png

This will shrink the image.

You can also resize images and keep the proportions:

convert *.jpg -resize 100x40 -set filename:original %t %[filename:original].png