Skip to content

Instantly share code, notes, and snippets.

@mateuslopes
Created June 5, 2012 03:48
Show Gist options
  • Save mateuslopes/2872512 to your computer and use it in GitHub Desktop.
Save mateuslopes/2872512 to your computer and use it in GitHub Desktop.
PHP+Image: Image Better Quality Filter
$img_r = imagecreatefromjpeg($src);
imagefilter($img_r, IMG_FILTER_BRIGHTNESS, 5);
imagefilter($img_r, IMG_FILTER_CONTRAST, -10);
$sharpenMatrix = array
(
array(-2, -1, -2),
array(-1, 40, -1),
array(-2, -1, -2)
);
// calculate the sharpen divisor
$divisor = array_sum(array_map('array_sum', $sharpenMatrix));
$offset = 0;
if($w < 1200){
// apply the matrix
imageconvolution($img_r, $sharpenMatrix, $divisor, $offset);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment