Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Resizing PNG - grey background - how to eliminate?


Reply


6 Posts   864 Views

Avatar
Ryan M.

Community Member, 309 Posts

28 September 2011 at 2:11pm

I don't think I've seen this discussed before and a search didn't turn up much. I'd like to know if anybody has any success in modifying the image resizing methods to accommodate PNG images that have transparency. It seems that in the process of resizing, it converts the image to a jpg and that gets rid of the transparency. Unfortunately, that results in a grey background, which looks quite ugly on some images that are meant to have transparency.

Any tips or suggestions please?

Avatar
zenmonkey

Community Member, 528 Posts

29 September 2011 at 8:27am

Which version of SS are you running. I remember it was an issue but works fine 2.4

Avatar
Ryan M.

Community Member, 309 Posts

29 September 2011 at 8:44am

I'm actually using 2.4.5

Avatar
zenmonkey

Community Member, 528 Posts

29 September 2011 at 9:00am

Only thing I can think of is your environment includes and older version of the GD library that doesn't support imagesavealpha(). The function used to keep transparency (its called in the silverstripe GD wrapper). I know I've had this problem on certain hosts when their "default" php build is missing some updated or usually included modules. Takes forever to debug those :)

Avatar
Ryan M.

Community Member, 309 Posts

29 September 2011 at 9:16am

The GD library came bundled with my server stack. It seems to be the latest version.
Running PHP 5.3.5 if that helps to know.

GD Support    enabled
GD Version    bundled (2.0.34 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.2.1
T1Lib Support    enabled
GIF Read Support    enabled
GIF Create Support    enabled
JPEG Support    enabled
libJPEG Version    6b
PNG Support    enabled
libPNG Version    1.2.10
WBMP Support    enabled
XPM Support    enabled
XBM Support    enabled

Avatar
zenmonkey

Community Member, 528 Posts

29 September 2011 at 9:27am

Hmm should be working, I know its working on 2.4.2 which leads me to believe its something to do with your specific install. Try writing a specific function to resize a png and see if fails. Something like this
http://www.akemapa.com/2008/07/10/php-gd-resize-transparent-image-png-gif/

Also check your logs to see if there's any error. I know the GD library actually needs a lot of memory if you're resizing a lot large images.

Finally check to make sure there aren't any extra alpha channels or paths in your image I know that has cause weird errors in the past for me