Answer the question
In order to leave comments, you need to log in
How to solve problem with bat script for Imagemagick to determine image width?
Hello, I'm trying to write a bat-nickname for Imagemagick to resize webp images in a folder with subfolders to two different sizes based on the width of the original image.
The problem is that the width of the image is not defined and ECHO width: %Width% returns an empty value. Tell me what's wrong?
@echo off
pushd %1
SET /A "MaxWidth=2000"
FOR /F "delims=" %%n IN ('dir /b /s /a-d-h-s') do (
For /F %%# in ("%~dp0identify.exe" -ping -format "%%[fx:w]" "*.webp") DO SET /A "Width=%%#"
ECHO width: %Width%
IF !Width! LSS !MaxWidth! ("%~dp0mogrify.exe" "%%n" -resize 1500x2000! "%%n") ELSE ("%~dp0mogrify.exe" "%%n" -resize 2000x1500! "%%n")
)
popd
echo All done!
PAUSE
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question