×
Kunena 5.2 Beta 1 Released (24 Sep 2020)

The Kunena team is thrilled to announce the first public beta release of Kunena 5.2, a native Joomla extension for Joomla 3.9. This is a development release and should be only be used for testing; this version is not recommended for live websites at this stage.

The purpose of this release is to encourage testing by downloading, installing and identifying any problems or shortcomings that people may discover. K 5.2.0 B1 is stable and we are aware that people will discover defects. We encourage you to use the forum to report defects, as soon as they are discovered, so that the development team can work through the problems before the release of K 5.1 as a stable product. Reporting defects does not mean that the problems can or will be fixed. The Kunena team is looking forward to hearing your feedback on how well we have achieved our design goals.

× 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
6 years 10 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
6 years 10 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.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Time to create page: 0.076 seconds