Re: [GD-DEVEL] GD Question

[email protected] (Pierre)
Newsgroups php.gd.devel
Message-ID <[email protected]>
Hi Tony, Derick!

On Jan 4, 2008 9:20 AM, Derick Rethans <[email protected]> wrote:
> On Thu, 3 Jan 2008, Tony wrote:
>
> > Hello. I wanted to ask if there is a way to write a text string to a JPEG
> > image such that the foreground color will always be visible regardless of the
> > underlying image?
>
> I've some code that analyses the background colour and draw the text on
> top of it in a readable colour. It works moderately well - it's written
> in PHP. This little script (attached) does it by word even, you will
> probably have to tweak it.
>

Tony, this code should work well for what you are looking for. An
optimization would be to pass the region of interest to the lightness
calculation function instead of calling it for each pixel.

This funciton (or for the other part of the HLS model) sounds like a
good addition to gd 2.1.

Returning one of the components, will also calc only this one, may be faster:
 (int) gdImageHLSComponentFromROI(gdImagePtr, gdRect, flag)
 (int) gdImageHLSComponent(gdImagePtr, x, y, flag)

Returns a HLS struct:
 (gdHLS) gdImageHLSFromROI(gdImagePtr, gdRect)
 (gdHLS) gdImageHLS(gdImagePtr, x, y)

Same for php, remove the gd prefix :)


-- 
Pierre
http://blog.thepimp.net | http://www.libgd.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.