Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
for /r %%f in (*.jpg) do (
magick convert "%%f" -thumbnail 324x248 win:
pause
)
When I run this code (windows NT,7,8,10 etc), a new IMDisplay window is opened (and a new imdisplay.exe process is created) each time a new image is 'converted'.
How do I get the first and subsequent images to use the same IMDisplay window?
(Being able, programmatically, to close the sub-windows within the IMDisplay main window would be useful too. Is it possible?)
Thanks.
Thanks, snibgo, I used your taskkill idea but also cmdow to manipulate windows. (cmdow is easily available)
I've copied in the windows bat file below if anyone wants to know how I added user-typed-in titles to my numerous jpg photos. (Helps when the photos are being viewed on a photoframe).
Magick issue:
In windows you can have filenames with spaces. In the script I found I had to alternatively use %~nxf1% in some magick commands and then in others I had to use just the filename. (I.E. I used set img=%~nxf1% followed by using %img% in the magick command)
cmdow issue: (not relevant on this blog - for information only)
calling cmdow /TOP and cmdow /ACT in no way guarantees that the window being acted on will have keyboard focus. Not only that but the functionality differs on windows XP and 10
REM You will need imagemagick (with magick in the path)
REM You will need cmdow (with cmdow in the path)
REM Cd to the directory containing photos (jpgs)
REM 'open a command window here'
REM annotatepics.bat IMG_1705.jpg <- example use
REM Or create a script that lists all the photos files and then runs this annotatepics.bat - see below at end
echo off
REM modified images are moved to annotated, originals in originals
mkdir annotated
mkdir originals
@title = "annotate program"
magick identify -format "%%W" "%~nx1%" > temp.txt
set /p width=<temp.txt
magick identify -format "%%H" "%~nx1%" > temp.txt
set /p height=<temp.txt
set /A thumbw=width/10
set /A thumbh=height/10
set /A texth=height/32
REM Note : if you dont do the following img=%~nx1% then magick 'convert' fails when the file name includes spaces
REM but note further that if you use %img% in the 'identify' commands above then magick will fail if
REM the file name contains spaces
set img=%~nx1%
magick convert "%img%" -thumbnail %thumbw%x%thumbh% win:
REM The following command moves the imdisplay window to the top left and makes it smaller
REM (Why cant this functionality be in the imdisplay.exe program?)
cmdow imdisplay* /MOV 0 0 /SIZ 400 400
REM The following command will potentially un-iconize another window in the system tray and
REM activate it over the top of everything. Best thing is to leave the newly uniconized window open and let it be pushed to the back
cmdow imdisplay* /INA
REM The @ here means the current window which is the cmd window running this script
REM The /TOP argument means fix this cmd window on top so you dont lose it
REM Note that on Windows 10 the /ACT argument does not guarantee that the window has keyboard focus
REM you might have to click on it to type the photo title in (very annoying)
cmdow @ /TOP
cmdow @ /ACT
set /p ptext=Photo Title ?
magick convert "%img%" -fill white -undercolor black -pointsize %texth% -gravity South -annotate +0+%texth% "%ptext%" "./annotated/title%img%"
magick convert "./annotated/title%img%" -thumbnail %thumbw%x%thumbh% win:
cmdow imdisplay* /MOV 0 0 /SIZ 400 400
cmdow imdisplay* /INA
cmdow @ /TOP
cmdow @ /ACT
pause
REM a bit of a brutal way of killing off the windows
taskkill /im imdisplay.exe
move "%img%" originals
del /Q temp.txt
REM Here's a script that will list out all the jpg images and then call the annotatepic.bat script (this script)
REM on each one of them :
REM echo off
REM del /Q annotateAll.bat
REM for /r %%f in (*.jpg) do (
REM echo annotatepics.bat "%%~nxf" >> annotateAll.bat
REM )
REM call annotateAll.bat
REM del /Q annotateAll.bat