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
How can I use convert -resize on a directory
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How can I use convert -resize on a directory
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
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How can I use convert -resize on a directory
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How can I use convert -resize on a directory
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
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
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How can I use convert -resize on a directory
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.
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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How can I use convert -resize on a directory
Thanks Anthony; The first choice is perfect.