How do I extract the author name and print it on the picture

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?".
Post Reply
Forssux
Posts: 3
Joined: 2014-05-07T04:24:07-07:00
Authentication code: 6789

How do I extract the author name and print it on the picture

Post by Forssux »

Hi There,

I'm using following script in a Windows world where I installed ImageMagick-6.8.9-Q16; users choose a picture that is send to Org-jpg-logo-IN
Then a logo is printed on it depending on the size of the original picture.
I was asked if I could print the name of the photgrapher on the picture. (example "John Doe Be Firm")
For some reason I only get "John"
Can somebody show me my error..

Code: Select all

::@echo on
set originale=D:\Org-jpg-logo-IN\
set converted=\\dgcmdc002\dalet\To-JPGHIRES-Logo\
set logo=C:\Program Files\ImageMagick-6.8.9-Q16\logo-full.png
for %%f in (%originale%*.jpg) do call :process %%~nxf
goto :eof
:process
SET filename=%1 %2 %3 %4 %5 %6
Set file=%originale%%filename%
FOR /F %%x IN ('identify -ping -format "%%w" "%file%"') DO SET width=%%x
FOR /F %%x IN ('identify -ping -format "%%h" "%file%"') DO SET hight=%%x
For /F %%x IN ('identify -format "\n%%[EXIF:copyright]" "%file%"') DO SET Author="Author"+%%x
set /a dimension=width*hight
echo file %file% >> %converted%\percent.txt
echo width %width% >> %converted%\percent.txt
echo hight %hight% >> %converted%\percent.txt
echo author %author% >> %converted%\percent.txt
set /a widthpercent=(width/7)
set /a hightpercent=(hight/7)
if %widthpercent% GTR %hightpercent% set /a percent=widthpercent 
if %hightpercent% GEQ %widthpercent% set /a percent=hightpercent
echo widthpercent %widthpercent% >> %converted%\percent.txt
echo hightpercent %hightpercent% >> %converted%\percent.txt
echo percent %percent% >> %converted%\percent.txt

::"C:\Program Files\ImageMagick-6.8.9-Q16\convert.exe" "%logo%" -resize %percent% "%converted%\%logo%"
"C:\Program Files\ImageMagick-6.8.9-Q16\convert.exe" "%logo%" -resize %percent%x%percent% %converted%\logo-tmp.png
::"C:\Program Files\ImageMagick-6.8.9-Q16\convert.exe" "%logo%" -resize %percent%x%percent% logo-tmp.png
"C:\Program Files\ImageMagick-6.8.9-Q16\composite.exe" "%converted%logo-tmp.png" "%file%" -dissolve 95 -gravity SouthEast "%converted%\95%filename%"
"C:\Program Files\ImageMagick-6.8.9-Q16\composite.exe" "%converted%logo-tmp.png" "%file%" -dissolve 75 -gravity SouthEast "%converted%\75%filename%"
"C:\Program Files\ImageMagick-6.8.9-Q16\composite.exe" "%converted%logo-tmp.png" "%file%" -dissolve 55 -gravity SouthEast "%converted%\55%filename%"


del "%originale%%filename%"
del "%converted%\logo-tmp.png"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How do I extract the author name and print it on the pic

Post by snibgo »

Code: Select all

FOR /F %%x IN (' ...
The above will copy the first token in the line into environment variable x. By default, tokens are separated by spaces. To pick up the entire line:

Code: Select all

FOR /F "tokens=*" %%x IN (' ...
snibgo's IM pages: im.snibgo.com
Forssux
Posts: 3
Joined: 2014-05-07T04:24:07-07:00
Authentication code: 6789

Re: How do I extract the author name and print it on the pic

Post by Forssux »

Hi snibgo,

thank you for the quick reply..
I changed the line to this FOR /F "tokens=*" %%x IN ('identify -format "\n%%[EXIF:Artist]" "%file%"') DO SET Artist=%%x
which works great

Thank you very much
Guy
Post Reply