Hello
I just wat to put some "TEXT-Messages" into several Pictures with a transparent Background - but i dont know how...
For usual Background at TEXT i use: -undercolor COLOR
So i get a text within the Picture and the Text "sit" in a Colored Box within the Picture - so fare so good...
But i want to have a Transparency Box in wich i have the TEXT-Message.
Because is use this in a automated Script with different TEXT Font´s and different Font Sizes i cannot "DRAW" the BOX manualy.
So how can i use -undercolor to do it Transparency - the best solution would be to if i can set the level of Transparency in Percent (1-100%)
Perhaps - anyone of you can help me
Sorry for poor English...
Best Regards.
GTR
Put a Text with transparent Background into a Image
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Put a Text with transparent Background into a Image
IM will not generally insert transparency as an undercolor, as far as I know.
I think what you have to do is:
1) Draw a block of color where you want to put your transparency. Some color that is not in your image at that spot.
2) Draw matte floodfill to fill that color with transparency
3) Draw or Annotate your text within that transparent area
see drawing a colored rectangle at http://www.imagemagick.org/Usage/draw/#primitives
see matte floodfill at http://www.imagemagick.org/Usage/draw/#matte
see putting text in your image with draw or annotate at
http://www.imagemagick.org/Usage/text/#draw
http://www.imagemagick.org/Usage/text/#annotate
I think what you have to do is:
1) Draw a block of color where you want to put your transparency. Some color that is not in your image at that spot.
2) Draw matte floodfill to fill that color with transparency
3) Draw or Annotate your text within that transparent area
see drawing a colored rectangle at http://www.imagemagick.org/Usage/draw/#primitives
see matte floodfill at http://www.imagemagick.org/Usage/draw/#matte
see putting text in your image with draw or annotate at
http://www.imagemagick.org/Usage/text/#draw
http://www.imagemagick.org/Usage/text/#annotate
Re: Put a Text with transparent Background into a Image
Hi
Thanks for your Answer
Because i use IM within a bigger Software wich should give some options to the user:
- Position of the Text
- Font-Size of the Text
- Text-Lenth
- Font Style
Im not able to calculate where the TEXT will be displayed on the Image and how log it is... - so im not able to draw the "Transparent" Box to the right position and with the right dimentions.
Perhaps i´m wrong ?
CU
Thanks for your Answer
Because i use IM within a bigger Software wich should give some options to the user:
- Position of the Text
- Font-Size of the Text
- Text-Lenth
- Font Style
Im not able to calculate where the TEXT will be displayed on the Image and how log it is... - so im not able to draw the "Transparent" Box to the right position and with the right dimentions.
Perhaps i´m wrong ?
CU
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Put a Text with transparent Background into a Image
You will need to set the undercolor as a semi-transparent color. Unfortunatally you can not currently specify a named color with a transparency value. If you want this, put in a suggestion in the Developers forum. I have been wanting that is for years myself!
See IM Examples, Color Specification
http://www.imagemagick.org/Usage/color_basics/#color
and the Offical Page, Color Names
http://www.imagemagick.org/script/color.php
For ways of annotating images using an surrounding 'undercolor' or 'dimmed box' see IM examples, Annotations
Labeling on top of the Image itself..
http://www.imagemagick.org/Usage/annotating/#anno_on
See IM Examples, Color Specification
http://www.imagemagick.org/Usage/color_basics/#color
and the Offical Page, Color Names
http://www.imagemagick.org/script/color.php
For ways of annotating images using an surrounding 'undercolor' or 'dimmed box' see IM examples, Annotations
Labeling on top of the Image itself..
http://www.imagemagick.org/Usage/annotating/#anno_on
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Put a Text with transparent Background into a Image
Anthony,
Are you saying if you specify the undercolor as "rgba(0,0,0,0)" one would have a completely transparent undercolor "forced" into an opaque image when annotating text?
Fred
Are you saying if you specify the undercolor as "rgba(0,0,0,0)" one would have a completely transparent undercolor "forced" into an opaque image when annotating text?
Fred
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Put a Text with transparent Background into a Image
Well I wouldn't say 'forced'. But it will be drawn. But as you know drawing transparency does nothing!
Try using rgba(0,0,0,0.5) to see undercolor effects.
Try using rgba(0,0,0,0.5) to see undercolor effects.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Put a Text with transparent Background into a Image
Anthony,
If I understand correctly, the originator of this topic is trying to write text to an opaque image where the undercolor is transparent in the sense that it makes the image transparent where the undercolor exists (i.e. a hole). Is this possible without something like the steps that I listed above?
Fred
If I understand correctly, the originator of this topic is trying to write text to an opaque image where the undercolor is transparent in the sense that it makes the image transparent where the undercolor exists (i.e. a hole). Is this possible without something like the steps that I listed above?
Fred
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Put a Text with transparent Background into a Image
Only by generating a separate image (such as a label), and using -compose copy to overlay it!
http://www.imagemagick.org/Usage/compose/#copy
Or erasing the original image to make the hole first.
http://www.imagemagick.org/Usage/compose/#copy
Or erasing the original image to make the hole first.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Put a Text with transparent Background into a Image
Yes, this seems to work:
convert logo: \( -size 100x -font /Library/fonts/arial.ttf -pointsize 24 -background none -fill black -gravity center label:"testing" \) -channel rgba -alpha set -gravity center -compose copy -composite tmp.png
convert logo: \( -size 100x -font /Library/fonts/arial.ttf -pointsize 24 -background none -fill black -gravity center label:"testing" \) -channel rgba -alpha set -gravity center -compose copy -composite tmp.png