Skip to content

Commit

Permalink
[Optimize] Generate thumbnail image method to avoid pixelated error i…
Browse files Browse the repository at this point in the history
…n thumbnails. Fixes #7919
  • Loading branch information
thongredweb authored and wilsonge committed Sep 3, 2016
1 parent 51a23f8 commit 0ba5a11
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion libraries/joomla/image/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ class JImage
*/
protected static $formats = array();

/**
* @var boolean True for best quality. False for speed
*
* @since __DEPLOY_VERSION__
*/
protected $generateBestQuality = true;

/**
* Class constructor.
*
Expand Down Expand Up @@ -420,7 +427,10 @@ public function crop($width, $height, $left = null, $top = null, $createNew = tr
// Set the transparent color values for the new image.
imagecolortransparent($handle, $color);
imagefill($handle, 0, 0, $color);
}

if (!$this->generateBestQuality)
{
imagecopyresized($handle, $this->handle, 0, 0, $left, $top, $width, $height, $width, $height);
}
else
Expand Down Expand Up @@ -550,7 +560,7 @@ public function isLoaded()
/**
* Method to determine whether or not the image has transparency.
*
* @return bool
* @return boolean
*
* @since 11.3
* @throws LogicException
Expand Down Expand Up @@ -749,7 +759,10 @@ public function resize($width, $height, $createNew = true, $scaleMethod = self::
// Set the transparent color values for the new image.
imagecolortransparent($handle, $color);
imagefill($handle, 0, 0, $color);
}

if (!$this->generateBestQuality)
{
imagecopyresized(
$handle,
$this->handle,
Expand Down Expand Up @@ -1178,4 +1191,18 @@ public function __destruct()
{
$this->destroy();
}

/**
* Method for set option of generate thumbnail method
*
* @param boolean $quality True for best quality. False for best speed.
*
* @return void
*
* @since 3.6.0
*/
public function setThumbnailGenerate($quality = true)
{
$this->generateBestQuality = (boolean) $quality;
}
}

0 comments on commit 0ba5a11

Please sign in to comment.