Page 1 of 1

Text Rotate + Alpha

Posted: 2011-06-11T06:27:14-07:00
by KandisZZ
Hello Forum.
Im searching for hours, with no good results.
Two Questions:

Code: Select all

convert -background none -gravity $align -font Fonts/$font -pointsize $arg[3] -size $arg[0]x$arg[1] -fill '#$arg[4]'  -rotate $arg[8]  caption:'$text' PNG:-
1. Text Rotating
I want to rotate the text on its own position. If I apply the location +0+0 operator, it won't work.
Want it like the Text 4, 5 and 6.
Image
(Picture from http://www.html46.com/Annotate_at_IM.html)

2. Transparency
I get an Hex Color Code for the fill operator. So I cant use the fill RGBA.
How can i use transparency either? Perfectly in percent from 0 - 100;

Greetings and much thx for helping me :)

Marc.

Re: Text Rotate + Alpha

Posted: 2011-06-11T09:46:01-07:00
by fmw42
I cannot answer question 1, but for question 2:

you can use hex colors for fill, they just get converted internally by IM to rgb(a), see http://www.imagemagick.org/script/color.php
e.g. -fill "#ffaacc" but be sure to enclose the hex value in quotes.

as for the transparency, you can use hex in your transparent color values again see http://www.imagemagick.org/script/color.php
alternately, you must use rgba(r%,g%,b%,x) or rgba(r,g,b,x) where x is between 0 and 1 again see http://www.imagemagick.org/script/color.php

so just divide your transparency in percent by 100 to get values between 0 and 1.

Re: Text Rotate + Alpha

Posted: 2011-06-11T18:02:58-07:00
by anthony
The real problem is that currently IM uses -gravity for BOTH positioning, and justification at that position.

However there is a way out of this problem, look at -draw with gravity. The examples for this is a little odd as it actually even pre-dates IM Examples!
IM Examples, Annotating, Text Positioning with Rotation
http://www.imagemagick.org/Usage/annota ... t_rotation

Until we get a proper justification setting for positioning both text and images on another image, that is the bast that can directly.

Indirectly is another matter! You can
  • render your text into a separate image, with whatever justification, (gravity) you want in that box
  • Now distort that image using SRT, with scale, rotation and more importantally translation to place the text where you want
  • and finally 'layer' the image onto the background.
The only problem with this technique is that you can't position or translate the image with 'gravity' you need to do this yourself by using some equations in the distort string.

I am sure a complete textual/image positioning system could be worked out using SRT distortion.
http://www.imagemagick.org/Usage/distort/SRT
It's arguments was designed with full positioning controls in mind, though only with absolute offsets. However as you can use % escapes you can make your own offsets, relative to the original image, or with some extra work even relative to some other (final destination) image. Also unlike other methods (direct compose) the positioning can be to a sub-pixel level.

Re: Text Rotate + Alpha

Posted: 2011-06-14T01:43:33-07:00
by KandisZZ
Thx for your help.

To the Color Thing:
I can only work with Hex Codes.
Theres a way to convert it in php with an external function, but its too slow.

Is there no way to add a alpha value direct to the hex (#123456).
Or add one to the command line (-alpha 50%).


thx again.

Re: Text Rotate + Alpha

Posted: 2011-06-14T03:57:34-07:00
by indiego
I use

... -fill xc:#FFFFFFD0

to fill some boxes with a transparent color. Donno if this works for you.

Re: Text Rotate + Alpha

Posted: 2011-06-14T10:13:57-07:00
by fmw42
Hex colors with alpha values are explained in the link I gave above at http://www.imagemagick.org/script/color.php Your hex values will be eight characters after the #. The last two are the alpha values. If you want 16-bit RGBA, you can do that as well, see the link above.

The questions is will your php code accept those hex values with alpha included?