1

I have this code to color text and add transparency it

  $draw->setFillColor('rgba(0,0,255,0.5)');

It's working perfectly but I want to do the same thing with hex format. How can I remplace 'rgba(0,0,255,0.5) to #0000FF ... I don't know how can I add the transparency parameter.

wxcvbn
  • 483
  • 2
  • 7
  • 20
  • Hex color codes with alpha values `#AARRGGBB` aren't supported in HTML. – mario Aug 25 '16 at 14:15
  • @mario, Is there an other way to add transparency to my text? – wxcvbn Aug 25 '16 at 14:16
  • 2
    Tith the `rgba(…)` syntax you already have, or with CSS `opacity:` – mario Aug 25 '16 at 14:17
  • @mario, Ok thank a lot! – wxcvbn Aug 25 '16 at 14:20
  • @mario, I don't believe this is duplicate. The OP is asking how ImageMagick parses color, specifically [parsing and querying color compliance](https://github.com/ImageMagick/ImageMagick/blob/master/MagickCore/color.c#L2217). CSS & HTML standards are not applicable (unless OP is working with SVG). – emcconville Aug 25 '16 at 17:22
  • 1
    Have you tried '#0000FF7F' ? i.e., hex #RRGGBBAA – Glenn Randers-Pehrson Aug 25 '16 at 18:57
  • The `#RRGGBBAA`/`#RGBA` notation is already available in some browsers (Firefox 49 beta and Chrome 52), but unlikely currently supported by ImageMagick. You could write a conversion function yourself. – Marat Tanalin Aug 25 '16 at 22:47

1 Answers1

1

you can use "dechex" to get an hexadecimal representation of the given unsigned number.

Mariella
  • 107
  • 1
  • 7
  • I don't understand, I already have the hexadecimal representation, but I need to add transparency and I don't know how to do this – wxcvbn Aug 25 '16 at 14:13
  • 1
    Sorry I misunderstand. You cannot insert alpha values in this way. You must use rgba or CSS opacity property – Mariella Aug 25 '16 at 14:17