Hello,

I was surprised to find that, although the GD image-handling functions shipped with PHP do many useful things very well, there's no function to sharpen an image. I found a few posts bemoaning this absence, and therefore attach a patch which adds the function

int imagesharpen ( resource im, int pct )

It performs the sharpening in-place. pct is the degree of sharpening to be applied: 0 does nothing; 100 gives a quite noticeable effect. Values >100 can be used for stronger sharpening. Negative values are treated as 0.

The routine only sharpens truecolor images, as it rarely makes sense to attempt the operation on palletted images.

It's a simple linear sharpening routine using a 3x3 kernel, rather than the more flexible, but slower, unsharp masking approach used in e.g. Photoshop, Imagemagick. However it's very effective at making resampled photographic images (such as thumbnails) look a little more crisp.

I've built and tested it using gcc 3.3 under Mac OS X 10.3.1. There's nothing I'd expect to be platform-dependent in it. The attached patch is against php4-STABLE-200311202030, but it should work with most varieties of php-4.3.4, as the new code is fairly self-contained.

This is my first patch for PHP. Is there anything else I should do, beyond posting it here?

Many thanks,


Paul.


--
Paul Troughton         http://paul.troughton.org/
mobile +44 7866 041144       home +44 1223 366900

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to