Kunena 6.2.5 & module Kunena Latest 6.0.7 released

The Kunena team has announce the arrival of Kunena 6.2.5 [K 6.2.5] which is now available for download as a native Joomla extension for J! 4.3.x/4.4.x/5.0.x. This version addresses most of the issues that were discovered in K 6.1 / K 6.2 and issues discovered during the last development stages of K 6.2

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
10 years 4 months 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
10 years 4 months 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.360 seconds