Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Optimize] Generate thumbnail image method for avoid Pixelated error of thumbnail. #7919

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 3.6.0
*/
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 @@ -1179,4 +1192,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
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and in this doc block we should add the @since 3.6.0 tag

public function setThumbnailGenerate($quality = true)
{
$this->generateBestQuality = (boolean) $quality;
}
}