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?


6 Posts   834 Views

Ryan M.

28 September 2011 at 2:11pm Community Member, 309 Posts

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?


29 September 2011 at 8:27am Community Member, 528 Posts

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

Ryan M.

29 September 2011 at 8:44am Community Member, 309 Posts

I'm actually using 2.4.5


29 September 2011 at 9:00am Community Member, 528 Posts

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 :)

Ryan M.

29 September 2011 at 9:16am Community Member, 309 Posts

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


29 September 2011 at 9:27am Community Member, 528 Posts

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

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