CMS MADE SIMPLE FORGE

CGSmartImage

 

[#9610] PNG transparent resize with glitches

avatar
Created By: Jocelyn Lusseau (kraygoon)
Date Submitted: Tue Oct 22 08:41:55 -0400 2013

Assigned To: Robert Campbell (calguy1000)
Version: 1.13
CMSMS Version: 1.11.9
Severity: Major
Resolution: Works For Me
State: Closed
Summary:
PNG transparent resize with glitches
Detailed Description:
When I use CGSmartImage with PNG transparent, it's producing some black lines.
Original image:
https://dl.dropboxusercontent.com/u/11814293/Temp/CGSmartImage/logo.png
Resized by CGSmartImage:
https://dl.dropboxusercontent.com/u/11814293/Temp/CGSmartImage/img-69284182f53e36796b8a036025313046.png

Fixing this bug within class.CGImageBase.php, replacing:

      // from supersizer
      $_rsrc = imagecreatetruecolor($width, $height);  
      $color = imagecolorallocatealpha($_rsrc, 0, 0, 0, 127);
      imagecolortransparent($_rsrc,$color);
      $this->_transparent = $color;
      return $_rsrc;

With (old code from previous CGSmartImage version):

      // from supersizer
      $_rsrc = imagecreatetruecolor($width, $height);		
      $color = imagecolorallocatealpha($_rsrc, 0, 0, 0, 127);
      imagecolortransparent($_rsrc,$color);
      // Turn off transparency blending (temporarily)
      imagealphablending($_rsrc, false);
      // Create a new transparent color for image
      $color = imagecolorallocatealpha($_rsrc, 0, 0, 0, 127);
      // Completely fill the background of the new image with allocated color.
      imagefill($_rsrc, 0, 0, $color);
      // Restore transparency blending
      imagesavealpha($_rsrc, true);
      $this->_transparent = $color;
      return $_rsrc;


History

Updates

Updated: 2013-11-16 09:30
resolution_id: => 11
state: Open => Closed