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)
Resize all images with specific res in folder
Resize all images with specific res in folder
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Resize all images with specific res in folder
"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 ...
... 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 .
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
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 .
snibgo's IM pages: im.snibgo.com
Re: Resize all images with specific res in folder
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 ?)
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 ?)
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC