Page 1 of 1

Resize all images with specific res in folder

Posted: 2013-08-17T03:41:19-07:00
by Rye
So let's say I have about 4000~+ images in a folder, all of different resolutions.

The task now is to:
1. Find all images with resolution of 256x384 inside the current folder
2. Resize them to 322x480
(if you are fixed on certain image type, let's assume png is the one for the sake of argument)

Is this possible with image Magic and Dos
(also another approach in linux would also be good, having both ways is always good)

Re: Resize all images with specific res in folder

Posted: 2013-08-17T04:42:57-07:00
by snibgo
"Resolution" normally means dots per inch (or centimetre etc), but I assume you mean width and height, in pixels.

One method: loop through all the images. For each image, if it is 256x384, resize it.

Most of this is simple scripting, not specific to ImageMagick.

For getting the width and height, I use this Windows snippet ...

Code: Select all

FOR /F "usebackq" %%L IN (`%IM%identify -format "WW=%%w\nHH=%%h" %SRC%`) DO set %%L
... where %SRC% is the filename.
It could be more complex, directly comparing width and height to 256 and 384, returning 0 or 1 (meaning whether to do the resize), eg with identify -format "%[fx:w == 256 && h == 384]". See http://www.imagemagick.org/script/escape.php and http://www.imagemagick.org/script/fx.php .

Re: Resize all images with specific res in folder

Posted: 2013-08-17T04:49:52-07:00
by Rye
I seem to have trouble understanding this one.

Lets say I have 1 png in the same folder with said resolution.

What do I have to add to your script in order for it to work (as it seems to do nothing as of yet... maybe I have to adjust the SRC ?)