When you crop or resize a transparent image (png/gif) with the JImage class, the transparency gets lost. The Joomla CMS does not directly use this class, but I found this out while developing the Form2Content component, which does use these JImage class functions.
With this sample code the issue can be reproduced. Please note that you need to set-up this piece of code in your Joomla environment. There's no way to reproduce this issue through the Joomla GUI.
$src = 'test.png'; // Path to a transparent image
$dstCropped= 'test_cropped.png'; // Path where the cropped image will be written
$dstResized= 'test_resized.png'; // Path where the resized image will be written
$srcImage = new JImage($src);
$dstImage = $srcImage->resize(100, 100, true);
$dstImage->toFile($dstResized, IMAGETYPE_PNG);
$dstImage = $srcImage->crop(100, 100, 0, 0, true);
$dstImage->toFile($dstCropped, IMAGETYPE_PNG);
Two transparent images should be generated.
One resized to 100 x 100 pixels and one cropped from the left top, 100 x 100 pixels.
The sizes are correct, but you will see that the two generated images have lost their transparency.
Windows NT XPS-15 6.2 build 9200 (Unknown Windows version Home Premium Edition) i586
PHP Version 5.4.26
Web Server Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.26
Joomla! Version Joomla! 3.3.6 Stable
Joomla! Platform Version Joomla Platform 13.1.0 Stable
I have made a working CLI example to reproduce this issue, but due to the upload restrictions I can't upload it here.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-12-31 08:07:45 |
Labels |
Added:
?
|
PR proposed is here:
#5558