5

not sure where but I came across as image hosting site that allows you to upload your image in a large format or to sharpen it.

I personally do not recall or know of any functions of GD library to sharpen image which might just be a different word for quality being up-ed.

If some one knows of a function to sharpen images please tell me since personally I am not aware of such functions neither in Image Magic and/or GD Library.

  • Thanks in advance
PT Desu
  • 693
  • 4
  • 13
  • 26

4 Answers4

6

You can use imageconvolution in GD with a sharpen mask. From http://adamhopkinson.co.uk/blog/2010/08/26/sharpen-an-image-using-php-and-gd/:

PHP and GD can sharpen images by providing a matrix to imageconvolution:

// create the image resource from a file
$i = imagecreatefromjpeg('otter.jpg');

// define the sharpen matrix
$sharpen = array(
  array(0.0, -1.0, 0.0),
  array(-1.0, 5.0, -1.0),
  array(0.0, -1.0, 0.0)
);

// calculate the sharpen divisor
$divisor = array_sum(array_map('array_sum', $sharpen));

// apply the matrix
imageconvolution($i, $sharpen, $divisor, 0);

// output the image
header('Content-Type: image/jpeg');
imagejpeg($i);
Walf
  • 8,535
  • 2
  • 44
  • 59
brian_d
  • 11,190
  • 5
  • 47
  • 72
5

You'd use imageconvolution() with a matrix that corresponds to a sharpen filter. Details in this comment on the PHP site: http://php.net/manual/en/ref.image.php#56144

Marc B
  • 356,200
  • 43
  • 426
  • 500
  • A so there was an image sharpening function, but personally never used imageconvolution() so would not know much about it – PT Desu May 26 '11 at 16:57
  • That's what most sharpen/unsharpen filters are in image editors - a convolution function with a matrix. – Marc B May 26 '11 at 16:58
1

I haven't tried it, but this looks like what you're looking for, as far as ImageMagick goes.

regularfry
  • 3,248
  • 2
  • 21
  • 27
0

In GD library of php having a file with path

lib/PHPImageWorkshop/Core/ImageWorkshopLayer.php

Please go to save public function and you can change the imageQuality upto 100. make sure which type of image you want to create. Hope this will help you.

Ami Kamboj
  • 105
  • 1
  • 10