converting images with command "convert"?

Discuss Programming

converting images with command "convert"?

Postby raptor » Thu Feb 05, 2004 10:28 pm

I have a cd full of images that i would just like to convert all of them to a certian resolution. How would i go about converting a whole cd of images to .png format and a screen resolution of 1024x768?

Thanks!
raptor
n00b
n00b
 
Posts: 1
Joined: Fri Jan 30, 2004 2:30 pm
Location: WA

Postby Void Main » Thu Feb 05, 2004 10:56 pm

Hmm, I would think something like this should do it:

Code: Select all
$ mkdir ~/pics
$ cd /mnt/cdrom
$ for i in `find | egrep -i ".jpg$|.gif$"`
> do
> convert -resize 1024x768 $i ~/pics/${i%%.[jJgG][pPiI][gGfF]}.png
> done


That should convert any gif and jpg files to png, resize them to 1024x768 and put them in your ~/pics directory. It should work, however there may be problems if you have spaces in your filenames. That can be worked around by adding some quotes. It also won't keep whatever subdirectory structure you have on your CD (it will put all the png files in one directory) so the names must be unique. That could be worked out as well.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests