set a variables with the width and height of a image in dos
Posted: 2011-08-31T08:55:16-07:00
I am starting a new thread because I was asked to.
I use Watch Directory as my service to set off the process. Due to that certain quotes have to stay in place for IM to get the passed parameters. ImageMagick requires certain things in quotes to recognize the symbols but I think DOS is also interpreting all these quotes. I have tried without single quotes but it assigns each of the code pieces in turn to the variable, not the result of the identify command. Any idea why this is not working or if there is a dos way to get this info from a jpg so I don't have to use the ImageMagick symbols to get it? Thanks for your help!
FOR /F %%x IN ('"C:\Program Files\ImageMagick-6.5.6-Q8\identify.exe" -ping -format "%%w" "%WD_FILE%"') DO SET IMGWIDTH=%%x
FOR /F %%y IN ('"C:\Program Files\ImageMagick-6.5.6-Q8\identify.exe" -ping -format "%%h" "%WD_FILE%"') DO SET IMGHEIGHT=%%y
IF %IMGWIDTH% LSS %IMGHEIGHT% ('"C:\Program Files\ImageMagick-6.5.6-Q8\convert.exe" "%WD_FILE%" -gravity center -extent 1000x1000 "\\harvardtest2\webimages\%WD_FILE_B%.jpg"')
IF %IMGHEIGHT% LSS %IMGWIDTH% ('"C:\Program Files\ImageMagick-6.5.6-Q8\convert.exe" "%WD_FILE%" -gravity center -extent 1500x1500 "\\harvardtest2\webimages\%WD_FILE_B%.jpg"')
Thank you for your time and help!
Cory Bonallo
I have searched the examples and documentation and believe I am very close. But, I do not understand something about how DOS uses quotes or ImageMagick syntax. I have working IM batches that I copied the syntax from originally.anthony wrote:Don't resurrect old threads especially ones 6 years old!
See IM examples, Windows Usage
http://www.imagemagick.org/Usage/windows/
This was not available when the original discussion was written.
I use Watch Directory as my service to set off the process. Due to that certain quotes have to stay in place for IM to get the passed parameters. ImageMagick requires certain things in quotes to recognize the symbols but I think DOS is also interpreting all these quotes. I have tried without single quotes but it assigns each of the code pieces in turn to the variable, not the result of the identify command. Any idea why this is not working or if there is a dos way to get this info from a jpg so I don't have to use the ImageMagick symbols to get it? Thanks for your help!
FOR /F %%x IN ('"C:\Program Files\ImageMagick-6.5.6-Q8\identify.exe" -ping -format "%%w" "%WD_FILE%"') DO SET IMGWIDTH=%%x
FOR /F %%y IN ('"C:\Program Files\ImageMagick-6.5.6-Q8\identify.exe" -ping -format "%%h" "%WD_FILE%"') DO SET IMGHEIGHT=%%y
IF %IMGWIDTH% LSS %IMGHEIGHT% ('"C:\Program Files\ImageMagick-6.5.6-Q8\convert.exe" "%WD_FILE%" -gravity center -extent 1000x1000 "\\harvardtest2\webimages\%WD_FILE_B%.jpg"')
IF %IMGHEIGHT% LSS %IMGWIDTH% ('"C:\Program Files\ImageMagick-6.5.6-Q8\convert.exe" "%WD_FILE%" -gravity center -extent 1500x1500 "\\harvardtest2\webimages\%WD_FILE_B%.jpg"')
Thank you for your time and help!
Cory Bonallo