Re: GD - Lame question, I know...

From: Date: Mon, 12 May 2003 08:08:57 +0000
Subject: Re: GD - Lame question, I know...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147268@lists.php.net to get a copy of this message
Jason B. Standing wrote:
I've seen a few posts talking about this GD thing, and thought I might try to do some reading to find out more about it... however searching the PHP docs didn't turn much up, and doing a Google search on "GD" sent back the kind of results you'd expect on a search criteria that vague... Can someone tell me a good spot to start from to learn about what GD is/does/etc. ?
The basic idea is to be able to spew out an image dynamically -- on-the-fly if you will -- from a PHP script. I posted an example yesterday, but just wrote another GD/PHP script much more interesting/fun today. Well, I thought it was more interesting/fun anyway. [background info -- skip down 5 paragraphs to the links to skip this] Among the many hats I wear, I admin a database of music venues for touring artists. I dunno if you've ever noticed, but music venues come and go (and change their name/ownership/management/policies) faster than restaurants. Thus, keeping the venue information up-to-date is rather challenging. That's why there is an automated system that lets volunteers sign up to be "assigned" an out-of-date entry to update, at any frequency they choose. There are also automated systems that contact the venues directly annually, lookup postal zip codes on USPS automatically, and cross-reference zip codes and longitude/latitude (US only so far) to enable the distance search functionality. But I digress. :-) Anyway, I've been wanting to get a handle on how "well" we're doing with keeping the venues up-to-date for a while now, and had a half-hour where I felt like working on that instead of something else I probably should have been working on today. :-^ What I came up with is a "progress meter" http://chatmusic.com/volunteer.htm That green/red image bar meter thing you see is a JPEG calculated in real time to display our success in keeping our data updated. You can right-click (or click-and-hold on a Mac) and load the JPEG in a separate window if you like. That JPEG is generated using PHP and GD. Here's the source code: http://chatmusic.com/venueprogressmeter.phps I didn't put in a lot of comments, but (A) it's just not that tricky, and (B) I kinda just hacked it up for myself, ya know? The only confusing part was that to get the "yellow" I wanted, I couldn't figure out how to get that in a smooth gradient between green/red, so I just slapped that switch() statement in there for the one-year-old and two-year-old data points. Crude, but effective. [more rambling -- just stop reading here if you're bored] Sure, it's somewhat "eye candy" but I'm hoping it will help motivate volunteers a bit -- and it certainly is useful to *ME* to keep an eye on whether we're "winning" or "losing" the data management battle. A few months ago, that bar would have been about 80% red. I intend to make it virtually all green or at least yellow before the year is finished. Oh yeah. If you're into music, you could invest five (5) minutes making sure we have your favorite live music venue in there with up-to-date info. :-) Then you could vote for your favorite music venue in our ongoing poll: http://chatmusic.com/favevenue.htm The whole thing is a wide-open to the public shared data project, and CHaT is a 501c3 non-profit organization, and the data will ALWAYS be free/public. Thanks! http://chatmusic.com/venues.htm#search

« previous php.general (#147268) next »