Page 1 of 2
Personnal signature in photos... Impossible to do...
Posted: 2007-01-15T14:01:33-07:00
by The Transporter
Hello all,
I'm a Belgian user of Imagemagick and I'm looking for a smart way to watermark my photos.
I read alot of tutorials, but no one could help me
The image you see that has been done in Gimp, like that, you can see better what I'm hardly trying to do...
This is the steps I want to do:
1) add a rectangle of X pixel on the bottom of the image with an alpha channel Y
2) Annotate it with my name on the bottom right
X and Y should be 2 variables in the script...
I succeded to draw a rectangle but it append it! How to draw a rectangle with alpha on top of the image ?
If you can give me some way to do it or some examples with documentation it would be great
Thanks in advance...
Posted: 2007-01-15T23:29:54-07:00
by anthony
See IM Examples, Annotate Images
Link in my signature.
Posted: 2007-01-16T13:23:48-07:00
by The Transporter
Hello Anthony,
I browsed your website again and again but what you tell me to do only put a box under the text.
Me I want a rectangle on the bottom of the image, on the whole bottom side. Is it possible ?
thanks
Posted: 2007-01-16T19:30:10-07:00
by anthony
A little further are to examples with annotation on the image!!!
one method is to draw the dim box, then annotate into that box,
The other is to use a 'undercolor box' using a semi-transparent color.
It is there and even headed...
Labeling on top of the Image itself...
http://www.cit.gu.edu.au/~anthony/graph ... /#label_on
Just modify the example as appropriate! Of course you may need to know how wide the image is to do it properly.
Here just for you I'll create another example
The first line just extracts the width of the image being annotated
Code: Select all
width=`identify -format %w logo:`
convert -size ${width}x80 -fill white -background '#0008' \
caption:'This is the Imagemagick Logo -- Annotated using Caption' \
+size logo: +swap -gravity south -composite caption_overlay.jpg
the convert then creates a caption with a semi-transparent background and overlays this
ontop of the image at the bottom. Note As I am using the latest IM I did NOT set a pointsize for the caption, but let it try to fill the given space at the best size posible.
try different heights for the caption box to adjust. and selete the desired font.
This has been added to the annotation page bt using the dragon image.
Posted: 2007-01-17T00:52:25-07:00
by The Transporter
Just one word: THANKS
Anthony your da man !
Thanks alot and keep up the good work!
Re: Personnal signature in photos... Impossible to do...
Posted: 2011-01-03T13:07:02-07:00
by The Transporter
Hello,
Sorry to dig up old topics but I'm wondering if it is possible to make a gradient of that background.
Instead of having a rectangle in the bottom filled with the same color, would it be possible to make an horizontal gradient, from transparent to that color ?
Thanks !
Re: Personnal signature in photos... Impossible to do...
Posted: 2011-01-03T13:40:31-07:00
by fmw42
make a gradient image the same width as your image and desired height, label it with label: or caption:, then append it to the bottom of your image.
see
http://www.imagemagick.org/Usage/canvas/#gradient
http://www.imagemagick.org/Usage/text/
http://www.imagemagick.org/Usage/layers/#append
Re: Personnal signature in photos... Impossible to do...
Posted: 2011-01-03T14:03:34-07:00
by The Transporter
Hello,
Thanks for the reply.
That's the question, I'm wondering how to make that rectangle on the top.
I'm trying to split up operations like:
- Drawing rectangle with gradient and put it on the original image at south.
- Draw text on the top of that image
Maybe I can use the previous command from Anthony to make the gradient in the rectangle ?
Currently I'm using this:
http://www.imagemagick.org/Usage/annotating/ (see the Auto-Sized Caption chapter)
Thx for the help !
Re: Personnal signature in photos... Impossible to do...
Posted: 2011-01-03T14:58:40-07:00
by Bonzo
This is in php but you will get the idea - same as the image in your first post with a gradiant:
Code: Select all
$input = 'House.jpg';
$size = getimagesize( $input );
$cmd = " $input ( -size {$size[0]}x30 gradient:black-white ".
" -fill red -pointsize 16 -gravity center".
" -annotate +0+0 \"Caption\" -flatten ) -append ";
exec("convert $cmd caption_size.jpg");
On the image itself with transparency
Code: Select all
<?php
$input = 'House.jpg';
$size = getimagesize( $input );
$cmd = " $input ( -size {$size[0]}x30 gradient:none-black ".
" -fill red -pointsize 16 -gravity center".
" -annotate +0+0 \"Caption\" ) -gravity south -composite ";
exec("convert $cmd caption_size.jpg");
?>
Re: Personnal signature in photos... Impossible to do...
Posted: 2011-01-03T16:39:33-07:00
by The Transporter
Hello,
Thanks for the script, it helped me a bit.
I'm trying to split the problem into different parts so I can understand the commands.
I already splitted up the gradient bar creation using this command:
Code: Select all
convert -size 30x1024 gradient:none-black -rotate -90 +repage gradient.png
Now, I'm using this to add it to the original image:
Code: Select all
composite -gravity South gradient.png $IMAGE $IMAGE
Now I need to find how to add a transparent text into the gradient.png bar before including it in the final image ($IMAGE)... any idea on this ?
Re: Personnal signature in photos... Impossible to do...
Posted: 2011-01-03T17:33:31-07:00
by fmw42
You cannot draw transparent text. But you can draw it in some color say red and then make red transparent.
convert -size 200x100 gradient: grad_tmp.png
convert grad_tmp.png -gravity center -fill red -pointsize 24 +antialias -draw "text 0,0 'TESTING'" -transparent red grad_tmp5.png
Re: Personnal signature in photos... Impossible to do...
Posted: 2011-01-03T18:51:04-07:00
by anthony
DON'T DO THAT!
Text with antialiasing turned off sucks! and that technique only works with anti-aliased text.
The solution is to create your gradient image, and a separate text image, then use the text image as a 'cookie cutter' for your gradient.
For example
Code: Select all
convert -size 200x100 gradient: gradient.png
convert -size 200x100 -background none -gravity center \
label:"Testing" png32:gradient_text_cutter.png
convert gradient.png gradient_text_cutter.png \
-alpha set -compose DstOut -composite png32:gradient_text_hole.png
+
->
See DstIn and DstOut
http://www.imagemagick.org/Usage/compose/#dstin
The gradient can be semi-transparent or anything you like.
Re: Personnal signature in photos... Impossible to do...
Posted: 2011-01-03T21:27:49-07:00
by fmw42
I believe Anthony means not to use aliased text (+antialias). His method (which I was about to add to a similar example to my text above above) is better as the mask image can have anti-aliased text (-antialias or default), which means the text is smoothed near its boundary and not stair-stepped. I was going to suggest making the same mask, but use -compose copy_opacity to add it as the transparency channel. See
http://www.imagemagick.org/Usage/compose/#copyopacity
Re: Personnal signature in photos... Impossible to do...
Posted: 2011-01-04T13:55:48-07:00
by The Transporter
anthony wrote:
For example
Code: Select all
convert -size 200x100 gradient: gradient.png
convert -size 200x100 -background none -gravity center \
label:"Testing" png32:gradient_text_cutter.png
convert gradient.png gradient_text_cutter.png \
-alpha set -compose DstOut -composite png32:gradient_text_hole.png
When I do those commands, the gradient.png is ok, but the gradient_text_cutter.png is black.
I also had to remove the png32 in front of the filenames to get them working.
About -compose DstOut, it's DstOut or Dst_Out ? (it's currently doing nothing because of the former problem with text.)
I'm using the binary version of Imagemagick(6.6.5) on Snow Leopard, I'm now compiling the macports version(6.6.6), I'll report here when it's finished because it's taking some time to get compiled.
Re: Personnal signature in photos... Impossible to do...
Posted: 2011-01-04T14:11:21-07:00
by fmw42
there are some issues with PNG that are being worked on and you should upgrade to the most current version if possible to get the most current improvements to PNG handling.
see
viewtopic.php?f=3&t=17771
and
viewtopic.php?f=3&t=17748
try creating all your PNG files with PNG32: prefacing the output filenames. See if that works.
The following works fine for me on IM 6.6.6.10 Q16 (hdri) Mac OSX Tiger
convert -size 200x100 gradient: gradient.png
convert -size 200x100 -background none -gravity center \
label:"Testing" png32:gradient_text_cutter.png
convert gradient.png gradient_text_cutter.png \
-alpha set -compose DstOut -composite png32:gradient_text_hole.png