Text on image - Replicating old film camera data backs
Posted: 2013-08-17T12:08:57-07:00
Hello folks,
I'm trying to replicate the look of the date and time that was imprinted on the old film SLRs with data back. They printed with a red lamp that left a glowing text on the photo.
My idea is to take the exif data and print date and time in a red text with a bit of blur to make it glow.
The code I'm debugging is below.
I'm writing the text to a transparent image that has the same size of the original, then I blur it then I composite it with the original.
The problem I have is: Once I composite the original and the text, I get a text that is not very bright. If on the other end I just flatten the transparent image on its own the text is very bright, so I guess the composite is not working as I intended. I think it may have something to do with the way I generate the alpha channel image?
Do you guys know what's wrong?
@echo off
CLS
SETLOCAL
:: Get image size:
FOR /F %%L IN ('identify -format "Width=%%w\nHeight=%%h" %1') DO set %%L
:: Get year/month/day and time separately
FOR /F "tokens=1,2,3,* delims=: " %%A IN ('identify -format "%%[EXIF:DateTimeOriginal]" %1') DO (set year=%%A & set month=%%B & set day=%%C & set time=%%D)
echo.
echo Year %year%
echo Month %month%
echo Day %day%
echo Time %time%
::Set a pointsize based on image size based on the shorter side of the picture (1/20th)
FOR /F %%i IN ('identify -format "%%[fx:min(w,h)/20]" %1') DO SET psize=%%i
echo.
echo PointSize Calculated is %psize%
:: Creates the offsets for the annotate position. The offsets are 1/30th on the long side and 1/20th on the short side
if %width% GTR %height% (
set /A AnnotateOffsetX=%width%/30
set /A AnnotateOffsetY=%height%/20
) else (
set /A AnnotateOffsetX=%width%/20
set /A AnnotateOffsetY=%height%/30
)
:: This is just the text picture and it looks nice and bright (font_fuzzy.jpg)
convert -size %width%x%height% xc:transparent -font DS-Digital -fill red -pointsize %psize% -strokewidth 2 -gravity southeast -annotate +%AnnotateOffsetX%+%AnnotateOffsetY% "%year%/%month%/%day% %time%" -blur 0x5 font_fuzzy.jpg
:: Here I create a transparent image with the same text as above to be combined with the original on a later step. (Alpha_Date.png)
convert -size %width%x%height% xc:transparent -font DS-Digital -fill red -pointsize %psize% -gravity southeast -annotate +%AnnotateOffsetX%+%AnnotateOffsetY% "%year%/%month%/%day% %time%" -channel RGBA -blur 0x5 Alpha_Date.png
:: Here I composite the two images, the Result.jpg has the text but is very dull, nothing like what it looks like in font_fuzzy.jpg.
composite -compose Dst_Over %1 Alpha_Date.png Result.jpg
I'm trying to replicate the look of the date and time that was imprinted on the old film SLRs with data back. They printed with a red lamp that left a glowing text on the photo.
My idea is to take the exif data and print date and time in a red text with a bit of blur to make it glow.
The code I'm debugging is below.
I'm writing the text to a transparent image that has the same size of the original, then I blur it then I composite it with the original.
The problem I have is: Once I composite the original and the text, I get a text that is not very bright. If on the other end I just flatten the transparent image on its own the text is very bright, so I guess the composite is not working as I intended. I think it may have something to do with the way I generate the alpha channel image?
Do you guys know what's wrong?
@echo off
CLS
SETLOCAL
:: Get image size:
FOR /F %%L IN ('identify -format "Width=%%w\nHeight=%%h" %1') DO set %%L
:: Get year/month/day and time separately
FOR /F "tokens=1,2,3,* delims=: " %%A IN ('identify -format "%%[EXIF:DateTimeOriginal]" %1') DO (set year=%%A & set month=%%B & set day=%%C & set time=%%D)
echo.
echo Year %year%
echo Month %month%
echo Day %day%
echo Time %time%
::Set a pointsize based on image size based on the shorter side of the picture (1/20th)
FOR /F %%i IN ('identify -format "%%[fx:min(w,h)/20]" %1') DO SET psize=%%i
echo.
echo PointSize Calculated is %psize%
:: Creates the offsets for the annotate position. The offsets are 1/30th on the long side and 1/20th on the short side
if %width% GTR %height% (
set /A AnnotateOffsetX=%width%/30
set /A AnnotateOffsetY=%height%/20
) else (
set /A AnnotateOffsetX=%width%/20
set /A AnnotateOffsetY=%height%/30
)
:: This is just the text picture and it looks nice and bright (font_fuzzy.jpg)
convert -size %width%x%height% xc:transparent -font DS-Digital -fill red -pointsize %psize% -strokewidth 2 -gravity southeast -annotate +%AnnotateOffsetX%+%AnnotateOffsetY% "%year%/%month%/%day% %time%" -blur 0x5 font_fuzzy.jpg
:: Here I create a transparent image with the same text as above to be combined with the original on a later step. (Alpha_Date.png)
convert -size %width%x%height% xc:transparent -font DS-Digital -fill red -pointsize %psize% -gravity southeast -annotate +%AnnotateOffsetX%+%AnnotateOffsetY% "%year%/%month%/%day% %time%" -channel RGBA -blur 0x5 Alpha_Date.png
:: Here I composite the two images, the Result.jpg has the text but is very dull, nothing like what it looks like in font_fuzzy.jpg.
composite -compose Dst_Over %1 Alpha_Date.png Result.jpg