protected function getThumb($thumbWidth, $thumbHeight, $sharpen = false) { if (!$this->image) { return null; } $srcX = 0; $srcY = 0; if ($this->width / $this->height > $thumbWidth / $thumbHeight) { $zoom = $this->width / $this->height / ($thumbWidth / $thumbHeight); $srcX = ($this->width - $this->width / $zoom) / 2; $this->width = $this->width / $zoom; } else { $zoom = $thumbWidth / $thumbHeight / ($this->width / $this->height); $srcY = ($this->height - $this->height / $zoom) / 2; $this->height = $this->height / $zoom; } $thumb = imageCreateTrueColor($thumbWidth, $thumbHeight); imageCopyResampled($thumb, $this->image, 0, 0, $srcX, $srcY, $thumbWidth, $thumbHeight, $this->width, $this->height); if ($sharpen && function_exists('imageconvolution')) { $sharpenMatrix = array(array(-1, -1, -1), array(-1, 16, -1), array(-1, -1, -1)); imageConvolution($thumb, $sharpenMatrix, 8, 0); } return $thumb; }
function image_cache_unsharp_mask(&$img) { imageConvolution($img, array(array(-1, -1, -1), array(-1, 25, -1), array(-1, -1, -1)), 16, 0); }