Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP GD sharpness filter

How can you make a sharpness filter with the PHP GD library?

So that this...

alt text

Turns to this...

alt text

If it is not possible with PHP, than what other languages are capable?

like image 661
Mark Lalor Avatar asked Dec 13 '25 04:12

Mark Lalor


2 Answers

I think he wants to use PHP's GD library. It's pretty easy: function.imageconvolution. Just search for 'sharpen' on the page and you'll see a matrix you can use for sharpening. It works pretty well, although I would recommend using ImageMagick if you're trying to do anything more than that.

like image 163
Tim Avatar answered Dec 14 '25 17:12

Tim


If the ImageMagick is installed in your PHP config, you can use Imagick::adaptiveSharpenImage

From the manual:

<?php
try {
    $image = new Imagick('image.png');
    $image->adaptiveSharpenImage(2,1);
} catch(ImagickException $e) {
    echo 'Error: ' , $e->getMessage();
    die();
}
header('Content-type: image/png');
echo $image;
?>

http://php.net/manual/en/function.imagick-adaptivesharpenimage.php

like image 20
Adam Hopkinson Avatar answered Dec 14 '25 17:12

Adam Hopkinson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!