Thanks to tip off from Jared “Ren” Williams (is that you? - any link?) here - the Cairo wrapper extension by Hartmut Holzgraefe - nice demo.
Cairo is the “next generation” vector graphics library for Linux and very cool to have it available in PHP. Also cool about the extension was created using PEAR::CodeGen_PECL, which Hartmut describes here: look Mum - no C! (well almost).
This raises the question of whether it’s time to depreciate GD? As far as I’m aware, it and the PCRE extension are the two main problem children preventing PHP from being thread safe. It may be possible to replace PCRE and preserve backwards compability, with ICU regexes, which claim to based on Perl’s regular expressions. Dropping GD would be much more painful but with Cairo and the imagick extension, there might be enough to keep everyone happy. This is in the interest of running PHP under Apache mpm. Would be interested to hear thoughts / opinions on how realistic that is?
Side note: my dumb view of the difference between GD and imagemagick is the former is more for image creation while the latter is more for manipulating existing images.






September 5th, 2006 at 11:38 pm
Yes, its me :)
September 6th, 2006 at 12:04 am
I do think GD should be deprecated and put into pecl. The quality of some of its drawing primitives aren’t that good. And the amount of effort to get it up to scratch seems wasted when there are existing usable api’s out there.
As for imagemagick, the magickwand api is definately suited to both creation and manipulation.
Draw*() & Pixel*() functions for creation, and Magick*() for manipulation.
http://www.magickwand.org/download/php/windows/manual/MagickWandForPHPManual.chm
Seems magickwand site seemingly has removed the gallery with one or two of my examples.
September 6th, 2006 at 12:26 am
A little nitpick…
“This is in the interest of running PHP under Apache MPM” is akin to saying “This is in the interest of running a script under PHP SAPI”, or “I opened it in Adobe.”
MPM == Multi-Processing Module, and if you use Apache 2, you already use an MPM–if you use PHP on anything but Windows, hopefully you use the prefork MPM (forks one child per request, just like Apache 1). The Worker MPM (which is what you meant, of course) is thread-based, and improves performance for most applications.
Also of interest (especially for virtual hosting) is the Perchild MPM, which also doesn’t work for the same (and different) reasons (-:
S
September 6th, 2006 at 3:34 am
one word
lighttpd
September 6th, 2006 at 8:33 am
Thanks for picked nit ;) That’s what I meant.
But that’s FastCGI
September 6th, 2006 at 5:05 pm
[…] Via Sitepoint « Noch mehr Cheat Sheets […]
September 6th, 2006 at 5:41 pm
[…] Gli amanti di Gnome conosceranno sicuramente Cairo, la libreria per la gestione/creazione di oggetti grafici vettoriali facente parte del progetto FreeDesktop. Oggi ho scoperto grazie a Harry Fuecks che č stato fatto un wrapper per la suddetta libreria per interfacciarsi con php. […]
September 7th, 2006 at 4:26 pm
Had a discussion with a colleague because of your blog (which is a good thing) and tried to find a list of thread-safe (or ZTS: “Zend Thread Safe”) extensions. Couldn’t find anything, and thus not really establish whether pcre is thread-safe or not (apart from your comment at http://programming.reddit.com/info/fhu0/comments).
Care to shed some light on it?
September 8th, 2006 at 6:51 pm
one word: mod_rewrite ;)
September 9th, 2006 at 7:28 am
Actually never seen anything like that either - I’ve seen PCRE and GD mentioned before (somewhere - perhaps PHP internals list - can’t remember) as being non-reentrant but perhaps I shouldn’t believe everything I read online.
You got me wondering more though and perhaps this highlights the problem with even compiling a list in the first place;
There’s also this remark (Andi Gutmans);
That seems to tally with what Sara Golemon says What the heck is TSRMLS_CC anyway? (comments);
That leads to some depressing conclusions.
September 9th, 2006 at 8:55 pm
I can’t see that last sequence being more than a few cpu instructions. I’d like to see some profiling data between the two, to see how much time it apparently takes over non-thread safe.
I’d bet other design decisions have a far greater impact on raw speed than the running with thread safety.
September 9th, 2006 at 9:02 pm
Indeed, but Rasmus has spelled them out(12 Dec. 2005)
It’s an answer just as cryptic as you’d expect from the Oracle at Delphi (not the IT-stuff, but Greek mythology). Why would and how could webservices make up for PHP extensions? GD-library via webservices? Did some more research and at some point my head started spinning with acronyms and comparing concepts I knew not too much about at all. Then decided to think “What an interesting discussion” and have a cup of tea.
December 10th, 2006 at 11:20 am
I have used both Imagemagick, and GD. I agree Imagemagick is powerful but it is also slow and resource hungry compared to the GD library. I think to deprecate GD would be a major step backwards for PHP. If thread safe is what you want need then disable GD on your own installation.
December 14th, 2006 at 11:30 am
[…] PHP extension for Cairo graphics library GD should be deprecated and put into pecl. The quality of some of its drawing primitives aren’t that good. And the amount of effort to get it up to scratch seems wasted when there are existing usable api’s out there. (tags: PHP Cairo) […]