Re: [GD-DEVEL] GD Question

From: Date: Fri, 04 Jan 2008 11:27:10 +0000
Subject: Re: [GD-DEVEL] GD Question
References: 1 2  Groups: php.gd.devel 
Request: Send a blank email to php-gd-devel+get-302@lists.php.net to get a copy of this message
Hi Tony, Derick! On Jan 4, 2008 9:20 AM, Derick Rethans <derick@php.net> 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

« previous php.gd.devel (#302) next »