Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
I got a image01.jpg and some 50 images in folder Y with different dimensions. I want to convert and resize image01.jpg 50 images have each the dimensions obtained folder Y 50 images and have the output in folder z.
With little hands on Batch scripting and googling: the below script does 50 image output to folder z but size is same as image01.jpg. Kindly help.
setlocal enabledelayedexpansion
%~d1
CD "%~p1"
MD small
FOR %%f in (*.jpg) DO (
set filename=%%f
identify -format "%%w" %%f > w.txt
set /p w=<w.txt
identify -format "%%h" %%f > h.txt
set /p h=<h.txt)
FOR %%f in (*.jpg) DO (
set filename=%%f
convert imageA.jpg -resize %w%x%h%! small\%%~nxf
)
)
You have a loop within a loop, so you will execute the convert 50*50 = 2500 times. You use the same loop variable %%f, which is very bad news. You assign values to w and h within a loop but use the %w% and %h% form, so won't use the correct values. Instead, you should use the !w! and !h! forms.