Jump to:

23481 Posts in 18965 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Resizing PNG - grey background - how to eliminate?

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

Page: 1
Go to End
Author Topic: 821 Views
  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Resizing PNG - grey background - how to eliminate? Link to this post

    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?

  • zenmonkey
    Avatar
    Community Member
    528 Posts

    Re: Resizing PNG - grey background - how to eliminate? Link to this post

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

  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Re: Resizing PNG - grey background - how to eliminate? Link to this post

    I'm actually using 2.4.5

  • zenmonkey
    Avatar
    Community Member
    528 Posts

    Re: Resizing PNG - grey background - how to eliminate? Link to this post

    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.
    Avatar
    Community Member
    309 Posts

    Re: Resizing PNG - grey background - how to eliminate? Link to this post

    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

  • zenmonkey
    Avatar
    Community Member
    528 Posts

    Re: Resizing PNG - grey background - how to eliminate? Link to this post

    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

    821 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.