Text Rotate + Alpha

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?".

Text Rotate + Alpha

Postby KandisZZ » 2011-06-11T06:27:14+00:00

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.
KandisZZ
 
Posts: 21
Joined: 2011-02-13T05:47:57+00:00

Re: Text Rotate + Alpha

Postby fmw42 » 2011-06-11T09:46:01+00:00

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.
User avatar
fmw42
 
Posts: 15011
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: Text Rotate + Alpha

Postby anthony » 2011-06-11T18:02:58+00:00

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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
http://www.imagemagick.org/Usage/
User avatar
anthony
 
Posts: 8732
Joined: 2004-05-31T19:27:03+00:00
Location: Brisbane, Australia

Re: Text Rotate + Alpha

Postby KandisZZ » 2011-06-14T01:43:33+00:00

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.
KandisZZ
 
Posts: 21
Joined: 2011-02-13T05:47:57+00:00

Re: Text Rotate + Alpha

Postby indiego » 2011-06-14T03:57:34+00:00

I use

... -fill xc:#FFFFFFD0

to fill some boxes with a transparent color. Donno if this works for you.
indiego
 
Posts: 75
Joined: 2010-10-16T06:35:10+00:00

Re: Text Rotate + Alpha

Postby fmw42 » 2011-06-14T10:13:57+00:00

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?
User avatar
fmw42
 
Posts: 15011
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA


Return to Users

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 11 guests

cron