Page 1 of 1
How can I use convert -resize on a directory
Posted: 2009-01-21T09:46:36-07:00
by kamalsofteng
Hi All;
I am trying to find a way to have convert -resize image1.jpg 1200x1200 image1_scled.jpg, work on an entire directory of images and put them in a sub directory or somewhere else. I am trying wild cards like "*.jpg" and it seems not to work or probably I am missing something...
Any ideas? everything is appreciated....
Thanks
Re: How can I use convert -resize on a directory
Posted: 2009-01-21T11:52:40-07:00
by fmw42
kamalsofteng wrote:Hi All;
I am trying to find a way to have convert -resize image1.jpg 1200x1200 image1_scled.jpg, work on an entire directory of images and put them in a sub directory or somewhere else. I am trying wild cards like "*.jpg" and it seems not to work or probably I am missing something...
Any ideas? everything is appreciated....
Thanks
use mogrify in stead of convert
see
http://www.imagemagick.org/Usage/basics/#mogrify
Re: How can I use convert -resize on a directory
Posted: 2009-01-21T18:00:14-07:00
by anthony
Also helps to give swap the "-resize image1.jpg" arguments so you read the image then resize with the right argument!
Code: Select all
convert image1.jpg -resize 1200x1200 image1_scled.jpg
Re: How can I use convert -resize on a directory
Posted: 2009-01-22T07:18:20-07:00
by kamalsofteng
Hi;
Thanks guys. I tried mogrify and it works perfect. I am issuing mogrify -path "C:\images\results" -resize x600 "C:\images\*.jpg".
Now, my next to-find is how to make the command generate two versions of the images, like one 600 px and one 150 px. Is there any idea. I could issue the same command twice, but I think if there is a way to do it once, you avoid re-reading the same images.
Thanks
Re: How can I use convert -resize on a directory
Posted: 2009-01-22T17:21:06-07:00
by anthony
You can either do mogrify twice,
Or run convert to output two images once for each image!
Writing an Image, Multiple Times
http://www.imagemagick.org/Usage/files/#write
You would script this in any case to do the extra processing like web index page generation.
I myself have done this for a long time. See
http://www.imagemagick.org/Usage/thumbnails/#html
Also the last example in
http://www.imagemagick.org/Usage/basics/#identify
The third choice is to use an API, like Perl, to loop over each image without closing imagemagick down for each separate 'shell' command.
Your choice.
Re: How can I use convert -resize on a directory
Posted: 2009-01-23T06:53:42-07:00
by kamalsofteng
Thanks Anthony; The first choice is perfect.