CMS MADE SIMPLE FORGE

CGSmartImage

 

[#11388] Resize of png doesnt work as expected

avatar
Created By: Tomas Amsrud (tamsrud)
Date Submitted: Wed May 24 04:27:29 -0400 2017

Assigned To: Robert Campbell (calguy1000)
Version: 1.21.9
CMSMS Version: 2.1.6
Severity: Major
Resolution: Works For Me
State: Open
Summary:
Resize of png doesnt work as expected
Detailed Description:
In 1.21.8 resize of transparent png creates artifacts in the transparent
regions.
Worked perfect in 1.21.5, but has a problem in 1.21.8 and 1.21.9.

When using filter_resize="h,200" it works ok, but has ugly edges (seems like ony
0% and 100% opacity).
When using height="200" the transparent regions gets artifacts.

When downgrading to 1.21.5, the problem is gone, and all png look fine again.

Include is set to "none" and default autoscale set to "resize"
I am also confused why height="200" and filter_resize="h,200" produces different
results.
But neither of them is ok.

Seems like it after 1.21.8 fails to produce transparent pngs with a 8-bit alpha
channel, so it only defines if a pixel is transparent or not.


History

Comments
avatar
Date: 2017-10-30 06:27
Posted By: Tomas Amsrud (tamsrud)

Problem persists in v1.22.1

If using width=410 it gets artifacts in the transparant regions.
If using filter_resize="w,410" there is no artifacts, but ugly edges.
      
avatar
Date: 2017-10-30 06:40
Posted By: Tomas Amsrud (tamsrud)

Sorry about last comment.
Not quite correct.

If using filter_resize="w,410" everyting works perfect.

But:
filter_resizetofit="410,410,transparent" - gets ugly edges
filter_croptofit="410,410" - gets artifacts

Examples:
http://silseth17.ekhweb.no/cgsmartimage-test
      
avatar
Date: 2017-10-30 07:08
Posted By: Tomas Amsrud (tamsrud)

Fix for resizetofit:

Add the following line 117:
imagesavealpha( $_dest['rsrc'], TRUE);

      
avatar
Date: 2018-03-09 04:52
Posted By: Stefano Quaranta (Brick)

tamsrud's solution works for me, I have the same problem even in v1.22.2.

But in my case I had to apply the workaround in 2 files:

1. (As tamsrud said) in class.CGImage_Resizetofit_Filter.php (At line 117)
2. In CGImage_Croptofit_Filter.php (At line 198)

Hope it will help to solve this bug.
      
avatar
Date: 2018-10-26 05:30
Posted By: Tomas Amsrud (tamsrud)

Problem persists in v1.22.4
      
avatar
Date: 2018-11-03 10:42
Posted By: Robert Campbell (calguy1000)

Just tested resizing with numerous filters with 2 different transparent PNG
images.
No issues here.
      
avatar
Date: 2018-11-09 03:31
Posted By: Tomas Amsrud (tamsrud)

I am using PHP 7.0.30 and GD 2.1.1 (Ubuntu 16.04 LTS).. If this has anything to
do with it.

I have tried to test now to trigger this problem.
It can look perfect on one image, but bad on another.

For example, on the image i am testing now, it looks fine with
filter_resizetofit="500,500,#ffffff" but has artifacts with
filter_resizetofit="518,518,#ffffff"
And if testing av image with width of 1000px it works fine, but not on a bigger
image with width of 2620px

Here are a link to examples of this problem:
https://www.ekh.no/cgsmartimage

Here are different filters. And the original image at the bottom.
If all of this look correct with you, I have to conclude that it is a bug with
my version of PHPor GD.
      
avatar
Date: 2018-11-22 16:02
Posted By: Robert Campbell (calguy1000)

This sounds more like a factor of your server and PHP environment 
I would try a different server/php environment to isolate the issue.
      
Updates

Updated: 2018-11-03 10:42
resolution_id: => 11