Hi guys, I've had a good look at some examples and the references, but its a bit of a steep learning curve, and I was hoping for a bit of help with a .bat for Windows.
I'd like to resize an image in a folder to multiple sizes if possible.
Assume I have a couple of .png images over 2000px square in a folder, I'd like to execute the .bat and have it create a folder per source image containing: 1024x1024, 512x512, 256x256, 128x128, 64x64, 32x32 re-sized versions of source image.
If someone could point me to a example I could modify, or idiotproof references, I'd be very grateful, Thankyou
Batch script to create multiple sizes of one image
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Batch script to create multiple sizes of one image
You have to do it one image at a time
convert image.jpg \
\( -clone 0 -resize 1024x1024 -write image_1024.jpg \) \
...
\( -clone 0 -resize 32x32 -write image_32.jpg \) \
null:
see parenthesis processing and clones at
http://www.imagemagick.org/Usage/basics/#parenthesis
On windows do not escape the parens with \ and replace the end of line \ with ^
see syntax differences at
http://www.imagemagick.org/Usage/windows/
convert image.jpg \
\( -clone 0 -resize 1024x1024 -write image_1024.jpg \) \
...
\( -clone 0 -resize 32x32 -write image_32.jpg \) \
null:
see parenthesis processing and clones at
http://www.imagemagick.org/Usage/basics/#parenthesis
On windows do not escape the parens with \ and replace the end of line \ with ^
see syntax differences at
http://www.imagemagick.org/Usage/windows/
Re: Batch script to create multiple sizes of one image
Excellent, got it working, thank you for your help
Re: Batch script to create multiple sizes of one image
I have encountered a slight hiccup though...
When run from cmd, it works as expected, but executed as a .bat from explorer, it give me... Invalid Parameter - -set
Any ideas?
When run from cmd, it works as expected, but executed as a .bat from explorer, it give me... Invalid Parameter - -set
Any ideas?
Code: Select all
@ECHO OFF
::Batch resize image to common sizes
convert In\* ^
-set filename:fname "%%f" ^
( -clone 0 -resize 1024x1024 -write Out\1024_%%[filename:fname] ) ^
( -clone 0 -resize 512x512 -write Out\512_%%[filename:fname] ) ^
( -clone 0 -resize 256x256 -write Out\256_%%[filename:fname] ) ^
( -clone 0 -resize 128x128 -write Out\128_%%[filename:fname] ) ^
( -clone 0 -resize 64x64 -write Out\64_%%[filename:fname] ) ^
( -clone 0 -resize 32x32 -write Out\32_%%[filename:fname] ) ^
null:
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Batch script to create multiple sizes of one image
I am not a windows user, but many scripting environments need you to provide the full path to convert.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Batch script to create multiple sizes of one image
"convert" in windows just happens to also be a silly utility that microsoft provided.
Commonly people rename "convert" to "im_convert" to avoid this.
IMv7 (in alpha development) will have a new command called "magick" that will replace "convert".
So I recommend you rename your "convert" command to "magick" instead, until IMv7 becomes
generally available.
This 'name change' ensures it to does not clash with existing utilities. The new command will also have a LOT of new features that are not available or have slight in-compatabilities with the older "convert" command.
Commonly people rename "convert" to "im_convert" to avoid this.
IMv7 (in alpha development) will have a new command called "magick" that will replace "convert".
So I recommend you rename your "convert" command to "magick" instead, until IMv7 becomes
generally available.
This 'name change' ensures it to does not clash with existing utilities. The new command will also have a LOT of new features that are not available or have slight in-compatabilities with the older "convert" command.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Batch script to create multiple sizes of one image
Cheers Anthony, that's the one!
Thanks for everyone's input.
Thanks for everyone's input.