> height = `identify -format '%h' target.jpg`
> width  = `identify -format '%w' target.jpg`

I assume that this works fine in a UNIX shell (or equivalent), but in a Windows environment it is not that easy. The return value of identify is written to stdout and in a DOS shell there is no way of storing it in a variable. Here is our code that works in a DOS shell:

-----------------------
set icon=logosw.svg
set percent=20
echo off
dir /s /b *.jpg > list

for /f "tokens=1 delims=" %%a in (list) do (
 echo %%a
 call getsize.bat %%a
for /f "tokens=1 delims=" %%f in (erg) do (call percent.exe %percent% %%f > erg2)
 for /f "tokens=1 delims=" %%b in (erg2) do (
  echo %%b
  imconv -resize x%%b %icon% icsmallx.tif
  composite -dissolve 20 -gravity southeast icsmallx.tif "%%a" "%%a.jpg"
 )
)
-----------------------

With getsize.bat being:

identify -format %%h %1 > erg

and percent.exe as a programm just calculating the percentage of the integer value supplied as a parameter. (This programm could possibly be substituted by Anthony's trick.)

In a DOS shell is that you have to 'save' the values provided by stdout in temporary files.

===================


With VBS it's getting somewhat easier. Here is sample code that uses the value provided by identify at stdout:

-----------------------
Dim wsh, objExec, strText, intSmall

Set wsh = CreateObject("Wscript.Shell")

command = "cmd /k identify -format %h test.jpg"
Set objExec = wsh.Exec(command)
strText = objExec.StdOut.Read(4)
intSmall=int(0.2 * strText)
WScript.Echo intSmall
-----------------------

So what do we draw from this? The DOS shell is a very rudimentary tool and things get slightly better if you use the new Windows onboard scripting tools. Using a bash shell sure is a possible solution - on your own computer...

Thanks for the hints.

Greetings from Münster, Germany
Wolfgang Hugemann


_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to