hoodwink.d enhanced
 

juretta.com

Rotate and resize images using Imagemagick | January 11, 2006-->

January 11, 2006

Let's assume that you have a bunch of images for which you want to create thumbnails. The thumbnails should be rotated 90 degrees counter clockwise (that is 270 degrees clockwise), scaled to a specific size and renamed from abc_large.png to abc_thumb.png.

powerbook:~ sts$ cat convert.sh
#!/bin/bash

# create directory for thumbnails
mkdir thumbs

# the large images are in ./images

for i in $(ls images/*.png)
do

# Rotate all images
img=`basename $i`
`convert -rotate 270 $i thumbs/$img`
echo "rotate $img"


# scale all images. replace suffix
new_name=`echo $img | sed s/_large/_thumb/`
`convert -scale 40x120 thumbs/$img thumbs/$new_name`
echo "scale thumbs/$new_name"


done

The following snippet crops all images in the current working directory to 222px x 185px. Furthermore the image type will be changed from gif to jpeg using the original image name. And all in one line of shell script.

Welcome to Darwin!
macbook-sts:~ stefan$ cd ~/images/
macbook-sts:~ stefan$ for i in $(ls); do name=`echo $i | sed s/\.gif/\.jpg/g`;\
convert -crop 222x185+0x0 $i $name; done
The convert command is part of the Imagemagick software package. See http://www.imagemagick.org/ for download and install instructions.

Diggman

Related Entries


About

juretta.com is the personal workspace of Stefan Saasen. You can send him an email or read more about this site in the „About“ section.

« Previous entry

IE 7 User Agent String
posted over 2 years ago

» Next entry

Shell sysadmin oneliner
posted over 2 years ago

Related Entries

Recent comment

On: “Attachr.com: OpenID support added

You need to kill this spam stuff!

posted about 1 year ago by entropie

Look!

Latest links  RSS  

More...