Problems with transparency in png images using 2.61

13 posts by 3 authors in: Forums > CMS Builder
Last Post: July 25, 2014   (RSS)

By gkornbluth - July 7, 2014

Hi All,

Has anyone else experienced issues with creating thumbnails of .png images in V. 2.61, or is it just me?

Have a look at the page at http://dancespotlight.com/png-test.php or http://thecmsbcookbook.com/png-test.php

It seems to have something to do with the ratio of the original size to the thumbnail size but I can’t seem to remedy the situation.

When I go below a ratio, any transparent areas are rendered as black in the thumbnails.

Doesn’t seem to matter if I’ve converted the .png from a jpg (in Photoshop) or if I downloaded it as a png, or if it’s an 8 bit or 24 bit png or which webhost and browser is being used.

(sorry but I don't have any older CMSB versions to test this on)

Thanks for any insights,

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Deborah - July 14, 2014

Hey, Jerry.

I set up a similar test with version 2.61 and see the same results you do. I tested on the same server with version 1.27 and didn't have a problem.

I changed the following image quality setting and the transparency was fine at any size thumbnail.

FILE: /lib/image_functions.php (approx line 63 & 64)

// resample image
$quality = 4; // v2.60 Speed up resizing (was 5 previously)

Here I changed: $quality = 4;     To: $quality = 5;

I can't say what impact the quality difference would have on a site when uploading or batch resizing a large quantity of images, but maybe upgrading the GD library on my server would accomplish this task with the lower quality setting. I didn't have time to look into that further, but maybe this will get you where you need to be today.

Hope that helps.

~ Deborah

By gkornbluth - July 14, 2014

Hi Deborah,

Thanks for the heads up, I'll give it a try and report back.

BTW, how did you discover the fix?

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Deborah - July 14, 2014

Jerry, I did a some online sleuthing and as a result of viewing posts from multiple sites, deducted that the image quality during resizing was a possibility. There must have been a valid reason for Interactive Tools to reduce the image quality in the 2.61 script. Maybe for some servers a faster processing speed is necessary.

~ Deborah

By Dave - July 15, 2014

Hi All, 

That is some amazing sleuthing, thanks!  

The adjustments to the image quality were to allow resizing/resampling of very large images that would otherwise be to slow or require too much memory.  How it works is we do a fast resizing of large images to something more manageable, then a smarter resampling down to the desired size.  Usually it doesn't look much different, but it looks like we're losing the transparency on the pngs.  

We'll do some research on this and post a patch/fix.

Stay tuned.

Dave Edis - Senior Developer
interactivetools.com

By gkornbluth - July 16, 2014

Thanks Dave.

I'll be on the lookout for your fix..

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Dave - July 16, 2014

Hi All, 

Here's a patched /cmsb/lib/image_functions.php (attached).  Can you try making a backup of your current image_functions.php and replacing it with this one?

I've added the code to maintain transparencies to the fast image resizing code, so you should be able to get the benefits of both now.

Let me know if this works for you.

Dave Edis - Senior Developer
interactivetools.com
Attachments:

image_functions.php 7K

By gkornbluth - July 17, 2014 - edited: July 17, 2014

Good morning Dave,

Tried the new file and it worked with both small (90K) and large (8MB) 24 bit .pngs

Thanks for staying on top of this.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Deborah - July 17, 2014

Dave, the patch works for my tests. All sizes of pngs have retained their transparency.

Thanks!
Deborah