With my work on imagecache_actions, I rapidly got sick of working with #HEX color conversions all the time.
But when I do, I parse them down into a nice array

Array
(
   [red] => 226
   [green] => 222
   [blue] => 252
   [alpha] => 0
)

the same way that PHP core represents it.
Because it's that much more portable, sensible and readable, especially when passing values around using the API.

I don't mind using #HEX values, but as you've recently found, you need alpha also #RRGGBBAA in many cases. The imageapi_hex2rgba() function currently does this well (I think) - but could do it one tiny step better. Do not rely on the order of attributes to define their meaning.

FWIW, I also think that the API would be cleaned up a lot if the hex value was converted to such a named array early on in the callstack, not leaving it to each action to decipher the HEX itself.
Change @param $background in all the actions from a hex string to a color array, possibly containing alpha information
(The functions can safely be modified to handle both methods for an interim period)

This suggestion has been in the back of my mind for months now..

Comments

drewish’s picture

i really think this should be against 7.x core since i'm trying to keep the two apis as close as i can.

dman’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

OK, against 7.x it is then.
That's a good enough chance to make a clean break, as it affects the documented API.
Shall I do the patch? This was initially a "what do you think?" sorta query. Worthwhile?

barraponto’s picture