Mogrify lightroom plug-in caption problem

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?".
d7e7r7

Re: Mogrify lightroom plug-in caption problem

Post by d7e7r7 »

Wow, thanks for the quick work... mustve taken you guys a while to write those codes?

I saved the php coding as a .bat file using Notepad but when I drop an image into it nothing happens so I opened it and saw
. Now I dont know this coding thing very well but how can I modify that line to change input to = the file that i drop onto the .bat file?

Another thins is where does the script save the processed file?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mogrify lightroom plug-in caption problem

Post by snibgo »

Here is a version of fmw's script, for Windows. I have added an undercolour, to help legibility.

Code: Select all

set INFILE=twooceansmarathon2494.jpg

convert %INFILE% -format "set WIDTH=%%w\nset CAPTION=%%[EXIF:ImageDescription]" info:cx.bat

call cx.bat

convert %INFILE% ^
( -size %WIDTH%x -background none -font Arial -fill white -undercolor "#00000080" caption:"%CAPTION%" ) ^
-gravity north -geometry +0+20 -composite captioned_%INFILE%
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mogrify lightroom plug-in caption problem

Post by snibgo »

You can't use PHP code directly in Windows batch files. But here is a batch file you can put on your desktop. Drop an image file on it, and it will create a captioned version in the same drive/directory of the image.

Code: Select all

set INFILE=%1

"%IMG%convert" %INFILE% -format "set WIDTH=%%w\nset CAPTION=%%[EXIF:ImageDescription]" info:cx.bat

call cx.bat

"%IMG%convert" %INFILE% ^
( -size %WIDTH%x -background none -font Arial -fill white -undercolor "#00000080" caption:"%CAPTION%" ) ^
-gravity north -geometry +0+20 -composite %~dpn1_captioned%~x1
snibgo's IM pages: im.snibgo.com
d7e7r7

Re: Mogrify lightroom plug-in caption problem

Post by d7e7r7 »

snibgo wrote:You can't use PHP code directly in Windows batch files. But here is a batch file you can put on your desktop. Drop an image file on it, and it will create a captioned version in the same drive/directory of the image.

Code: Select all

set INFILE=%1

"%IMG%convert" %INFILE% -format "set WIDTH=%%w\nset CAPTION=%%[EXIF:ImageDescription]" info:cx.bat

call cx.bat

"%IMG%convert" %INFILE% ^
( -size %WIDTH%x -background none -font Arial -fill white -undercolor "#00000080" caption:"%CAPTION%" ) ^
-gravity north -geometry +0+20 -composite %~dpn1_captioned%~x1
I made that into a .bat file and dropped an image onto it and it seemed to work but it doesn't create a new file when it finishes. Attached a screen shot: http://img121.imageshack.us/img121/2830/57980889.png
That screen shot is from the second last command, the last command happens as the cmd dialog closes so I cannot get a screenshot in time :lol:
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Mogrify lightroom plug-in caption problem

Post by Bonzo »

el_suprimo recomends putting "" around file names to help keep them together and that may be your problem, also the code produces a tempory file which can be removed.
I tend to put the bat file onto my desktop.

Code: Select all

:: Set the variable INFILE equal to the original file name
set INFILE=%1

:: Setup the width of the caption container - the width of the original image - and get the caption text from the EXIF data
:: Saved as cx.bat
"%IMG%convert" %INFILE% -format "set WIDTH=%%w\nset CAPTION=%%[EXIF:ImageDescription]" info:cx.bat

:: Load the cx.bat file ?
call cx.bat

:: Add the caption to the image and save with _captioned at the end of the original filename
"%IMG%convert" %INFILE% ^
( -size %WIDTH%x -background none -font Arial -fill white -undercolor "#00000080" caption:"%CAPTION%" ) ^
-gravity north -geometry +0+20 -composite "%~dpn1_captioned%~x1"

:: Delete tempory batch file
echo Y | DEL *cx.bat*
d7e7r7

Re: Mogrify lightroom plug-in caption problem

Post by d7e7r7 »

Bonzo wrote:el_suprimo recomends putting "" around file names to help keep them together and that may be your problem, also the code produces a tempory file which can be removed.
I tend to put the bat file onto my desktop.

Code: Select all

:: Set the variable INFILE equal to the original file name
set INFILE=%1

:: Setup the width of the caption container - the width of the original image - and get the caption text from the EXIF data
:: Saved as cx.bat
"%IMG%convert" %INFILE% -format "set WIDTH=%%w\nset CAPTION=%%[EXIF:ImageDescription]" info:cx.bat

:: Load the cx.bat file ?
call cx.bat

:: Add the caption to the image and save with _captioned at the end of the original filename
"%IMG%convert" %INFILE% ^
( -size %WIDTH%x -background none -font Arial -fill white -undercolor "#00000080" caption:"%CAPTION%" ) ^
-gravity north -geometry +0+20 -composite "%~dpn1_captioned%~x1"

:: Delete tempory batch file
echo Y | DEL *cx.bat*
Thanks Bonzo, that coding worked!! created a new file but the caption is pretty illegible, is there a way to make it larger?
See captioned file here: http://img693.imageshack.us/img693/1386 ... 2125ca.jpg
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Mogrify lightroom plug-in caption problem

Post by Bonzo »

Give somebody some help and they just want more !

This WIDTH=%%w\nset sets the width variable of the caption box to the width of the image.

( -size %WIDTH%x -background none -font Arial -fill white -undercolor "#00000080" caption:"%CAPTION%" ) ^
-gravity north -geometry +0+20 -composite "%~dpn1_captioned%~x1"

-size "caption box size" -background "caption box colour in this case transparent" -font "font to use and you can input the path to a font anywhere on the PC" -fill "colour of the font" -undercolor "clolour behind the font" -gravity " position on the image - think main compass points " -geometry "offset amount from -gravity"

Add a -pointsize 80 and see what it looks like; then go from there.

Code: Select all

:: Add the caption to the image and save with _captioned at the end of the original filename
"%IMG%convert" %INFILE% ^
( -size %WIDTH%x -background none -font Arial -pointsize 80 -fill white -undercolor "#00000080" caption:"%CAPTION%" ) ^
-gravity north -geometry +0+20 -composite "%~dpn1_captioned%~x1"
d7e7r7

Re: Mogrify lightroom plug-in caption problem

Post by d7e7r7 »

Bonzo wrote:Give somebody some help and they just want more !

This WIDTH=%%w\nset sets the width variable of the caption box to the width of the image.

( -size %WIDTH%x -background none -font Arial -fill white -undercolor "#00000080" caption:"%CAPTION%" ) ^
-gravity north -geometry +0+20 -composite "%~dpn1_captioned%~x1"

-size "caption box size" -background "caption box colour in this case transparent" -font "font to use and you can input the path to a font anywhere on the PC" -fill "colour of the font" -undercolor "clolour behind the font" -gravity " position on the image - think main compass points " -geometry "offset amount from -gravity"

Add a -pointsize 80 and see what it looks like; then go from there.

Code: Select all

:: Add the caption to the image and save with _captioned at the end of the original filename
"%IMG%convert" %INFILE% ^
( -size %WIDTH%x -background none -font Arial -pointsize 80 -fill white -undercolor "#00000080" caption:"%CAPTION%" ) ^
-gravity north -geometry +0+20 -composite "%~dpn1_captioned%~x1"
Sorry for all the trouble, coding just isn't for some people ;)
I managed to find a freeware app that is pretty much a GUI of what you guys are coding (i think?) http://www.gphotoshow.com/exif-iptc-watermarker.php
Thanks again!!!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Mogrify lightroom plug-in caption problem

Post by Bonzo »

Give somebody some help and they just want more !
I was only joking.
Post Reply