Personnal signature in photos... Impossible to do...

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?".
The Transporter
Posts: 14
Joined: 2007-01-15T13:54:49-07:00

Re: Personnal signature in photos... Impossible to do...

Post by The Transporter »

Yeah it works perfectly now :)
I'm using imagemagick 6.6.6-3 from macports.

This is the result:

Image

Now the script to do this:

Code: Select all

#!/bin/sh
IMAGE=$1
CAPTION="BMW's By Night | Photos by Pol D. | through-my-eyes.be"
FONT="./fonts/BMW75.TTF"
BORDERWIDTH="6"
BORDERWIDTH2="1"

width=`identify -format "%w" $IMAGE`
heigth=`identify -format "%h" $IMAGE`

convert -size 20x${width} gradient:none-white -rotate -90 +repage gradient.png

convert -size ${width}x20 -background none -fill white -font $FONT -gravity East label:"`echo $CAPTION`" text_mask.png

convert gradient.png text_mask.png -alpha set -compose Dst_Out -composite gradient.png

composite -gravity South gradient.png $IMAGE $IMAGE
rm gradient.png text_mask.png

mogrify -bordercolor white -border "${BORDERWIDTH}x${BORDERWIDTH}" $IMAGE
mogrify -bordercolor black -border "${BORDERWIDTH2}x${BORDERWIDTH2}" $IMAGE
The next part of the trick now would be to paint the font with a gradient but in the other direction.
In this example, a cool stuff would be to have the text in gradient FROM black TO transparent, do you think it can be doable also ?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Personnal signature in photos... Impossible to do...

Post by Bonzo »

Out of interest have you seen this site: http://www.mariusaasheim.com/
The Transporter
Posts: 14
Joined: 2007-01-15T13:54:49-07:00

Re: Personnal signature in photos... Impossible to do...

Post by The Transporter »

Bonzo wrote:Out of interest have you seen this site: http://www.mariusaasheim.com/
breathless !!! Woaw ! I still need to learn how to make HDR !!!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Personnal signature in photos... Impossible to do...

Post by anthony »

NOTE on your use of gradient with a hole.
With a long gradient the hole in it will be basically surrounded by a white overlay.
If that was overlay on a pure white image, your text 'hole' will vanish.

To make your label work properly you need to not only lighten the background using a semi-transparent gradient, but also darken the foreground slightly with an black semi-transparency.

This is talked about in IM Examples, Annotating Images, Annotating On top of the Image
http://www.imagemagick.org/Usage/annotating/#anno_on

NOTE that once you have an overlay image, you do not need to re-create it (unless the text changes), just compose it onto each image you want to label.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Personnal signature in photos... Impossible to do...

Post by anthony »

Bonzo wrote:Out of interest have you seen this site: http://www.mariusaasheim.com/
Very nice images, This guy certainly knows about photography, including using telescopes, though seems to like cars and car racing more than anything else. However while his bottom annotation label is good, the water mark he adds to the middle of the is not so good. It should always be visible to some extent in every photo, but it only is apparent in a few photos, like his moon shots.

Of course people who want such images would want them at maximum quality, but still he should protect them better.

Watermarking techniques.
http://www.imagemagick.org/Usage/annota ... termarking
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
The Transporter
Posts: 14
Joined: 2007-01-15T13:54:49-07:00

Re: Personnal signature in photos... Impossible to do...

Post by The Transporter »

Hello all,

I succeded to do what I wanted finally ;-)

Here is the whole script explained, for beginners who want to do the same... I help them also ;-)

Code: Select all

#!/bin/sh -x
IMAGE=$1
# The Caption
CAPTION="Set Your Caption Here"
# The Font Size
POINTSIZE="24"
# The path to a font.
FONT="./fonts/BMW75.TTF"

# Calculate the width of the original image.
width=`identify -format "%w" $IMAGE`

# Make a rectangular gradient from transparent to white, with a the width corresponding to the original image. 
convert -size 20x${width}e gradient:none-white -rotate -90 +repage gradient.png

# Make a mask using the caption. Transparent background, white font.
convert -size x20 -background none -fill white -font $FONT -gravity East label:"`echo $CAPTION`" text_mask.png
# Make a mask using the caption. Transparent background, white font, width is from original image.
convert -size ${width}x20 -background none -fill white -font $FONT -gravity East label:"`echo $CAPTION`" text_mask2.png

# Calculate it's width
width2=`identify -format "%w" text_mask.png`

# Make a rectangular gradient from black to transparent, it's width is calculated from the text_mask.png
convert -size 20x${width2} gradient:black-none -rotate -90 +repage gradient2.png

# Replace the white color of the text with the gradient2.png and make a new image: text.png
convert gradient2.png text_mask.png -alpha set -compose Dst_In -composite text.png

# Crop the text.png
mogrify -crop ${width2}x20+0+0 text.png

# Make a new empty png image: empty.png
convert -size ${width}x20 xc:none empty.png

# Paste the text.png into that empty image and overwrite text.png
convert -gravity East empty.png text.png -compose Over -composite text.png

# Take the gradient remove the text.png from it, make it transparent.
convert gradient.png text_mask2.png -compose Dst_Out -composite gradient.png

# Take the gradient and paste the text.png over it.
convert gradient.png text.png  -compose Over -composite gradient.png

# Copy the gradient.png on the south of the image.
composite -gravity South gradient.png $IMAGE $IMAGE

# Delete temporary files
rm empty.png gradient.png gradient2.png text_mask.png text.png
How to use this code:
1) Create a file: sig.sh, copy the code in it, then 'chmod +x' it.
2) Run this:

Code: Select all

./sig.sh image.jpg
Maybe you'll see some improvements, just let me know !

Thanks again for your help... 4 years after ;-)
Post Reply