Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5688 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61974 invoked by uid 1010); 24 Nov 2003 15:10:54 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 61939 invoked from network); 24 Nov 2003 15:10:54 -0000 Received: from unknown (HELO sphinx.mythic-beasts.com) (195.82.107.246) by pb1.pair.com with SMTP; 24 Nov 2003 15:10:54 -0000 Received: from future-is.orange.co.uk ([193.35.129.169] helo=[172.23.174.95]) by sphinx.mythic-beasts.com with asmtp (Exim 3.33 #3) id 1AOILR-0001zP-00; Mon, 24 Nov 2003 15:09:47 +0000 Mime-Version: 1.0 (Apple Message framework v606) Message-ID: <3BE30005-1E90-11D8-A3ED-000A95D9ABDE@troughton.org> Content-Type: multipart/mixed; boundary=Apple-Mail-22--962413191 To: internals@lists.php.net Date: Mon, 24 Nov 2003 15:09:43 +0000 X-Mailer: Apple Mail (2.606) Subject: [PATCH] Image sharpening function for ext/gd From: php@troughton.org (Paul Troughton) --Apple-Mail-22--962413191 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed 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 --Apple-Mail-22--962413191--