Kunena 6.3.7 Released

The Kunena team has announce the arrival of Kunena 6.3.7 [K 6.3.7] in stable which is now available for download as a native Joomla extension for J! 4.4.x/5.0.x/5.1.x/5.2.x. This version addresses most of the issues that were discovered in K 6.2 / K 6.3 and issues discovered during the last development stages of K 6.3
Note: Please go to the Kunena Dashboard after an upgrade so that the Kunena database tables are also updated.

Please note: The Kunena project team takes NO responsibility for maintaining nor supporting anything in this category.

Loved Error 500 - Internal server error when uploading and resizing images - my solution using IMAGICK

More
11 years 1 week ago #1 by WolfgangOWL
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;
}

Please Log in or Create an account to join the conversation.

More
11 years 1 week ago #2 by WolfgangOWL
The construct

if ( extension_loaded('imagick') && getimagesize($this->fileTemp)[2] == 2 )
{
...
}

may not work with older PHP versions. To be safe use the following code instead:

$testImagick = getimagesize($this->fileTemp);
if ( extension_loaded('imagick') && $testImagick[2] == 2 )
{
...
}

Please Log in or Create an account to join the conversation.

Time to create page: 0.463 seconds