Skip to content

Commit

Permalink
add backwards compatibility for PHP Version < 5.5 for image resize
Browse files Browse the repository at this point in the history
  • Loading branch information
ximex committed Nov 12, 2016
1 parent b1c30e8 commit aa81a07
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions adm_program/system/classes/image.php
Expand Up @@ -303,8 +303,20 @@ public function scale($newXSize, $newYSize, $maintainAspectRatio = true)
@ini_set('memory_limit', '50M');
}

// create new resized image
$resizedImageResource = imagescale($this->imageResource, $newXSize, $newYSize);
if (version_compare(PHP_VERSION, '5.5.0', '>='))
{
// create new resized image
$resizedImageResource = imagescale($this->imageResource, $newXSize, $newYSize);
}
else // backwards compatibility for PHP-Version < 5.5
{
// create a new image
$resizedImageResource = imagecreatetruecolor($newXSize, $newYSize);

// copy image data to a new image with the new given size
imagecopyresampled($resizedImageResource, $this->imageResource, 0, 0, 0, 0, $newXSize, $newYSize, $this->imageWidth, $this->imageHeight);
}

imagedestroy($this->imageResource);

// update the class parameters to new image data
Expand Down

0 comments on commit aa81a07

Please sign in to comment.