When users at our forum uploaded oversized imagages they got an error 500. I looked into the matter and found out that GD is eating up too much memory. I tried out IMAGICK and this is working fine without producing errors. So I modified kunena.upload.class.php and following is the code I use now. Maybe someone with more experience than me can modify it so that all allowed image formats will be processed by IMAGICK. I would be gratetful if in future versions of Kunena IMAGICK would be supported.
// If image is not inside allowed size limits, resize it
if ($this->fileSize > $this->imagesize || $this->imageInfo->width > $this->imagewidth || $this->imageInfo->height > $this->imageheight)
{
// test if imagick is loaded and image is jpeg
if ( extension_loaded('imagick') && getimagesize($this->fileTemp)[2] == 2 )
{
$imageImagick = new Imagick($this->fileTemp);
$imageImagick->setImageCompression(Imagick::COMPRESSION_JPEG);
$imageImagick->setImageCompressionQuality($this->imagequality);
$imageImagick->resizeImage($this->imagewidth, $this->imageheight, imagick::FILTER_LANCZOS, 1.0, true);
$imageImagick->writeImage($this->fileTemp);
$imageImagick->destroy();
}
else
{
$options = array('quality' => $this->imagequality);
$imageRaw = new CKunenaImage($this->fileTemp);
if ($imageRaw->getError())
{
$this->fail(JText::_($imageRaw->getError()));
return false;
}
$image = $imageRaw->resize($this->imagewidth, $this->imageheight);
$type = $imageRaw->getType();
unset($imageRaw);
$image->toFile($this->fileTemp,$type,$options);
}
clearstatcache();
// Re-calculate physical file size: image has been shrunk
$stat = stat($this->fileTemp);
if (! $stat) {
$this->fail(JText::_('COM_KUNENA_UPLOAD_ERROR_STAT', $this->fileTemp));
return false;
}
$this->fileSize = $stat;
}