WordPress.org

Forums

[Plugin: NextGEN Gallery] How to change black background in image with transparency? (8 posts)

  1. estr
    Member
    Posted 5 years ago #

    Hello,

    Could anyone please tell how can thumbnails of images with transparencies be displayed with white background instead of black one?

    I have tried modifying gallery style, but to no avail. And adding background to images in an image editor is not an option, as pictures need to have transparencies.

    Thank you!

  2. estr
    Member
    Posted 5 years ago #

    I just noticed that it is not a styling issue, it is how transparency is being handled by the core during resizing, because resized thumbnail files have black background themselves.

    Could anyone please direct me what needs to be changed in the core to keep transparency or make it white?

  3. estr
    Member
    Posted 5 years ago #

    I guess to fix this problem, some function needs to be added to gd.thumbnail.inc.php file.

  4. estr
    Member
    Posted 5 years ago #

    Have found an article, with code sample, that discusses this problem - PHP-GD: Resize Transparent Image PNG & GIF.

    It says that: "By default, you will get black background if you resize a transparent image. To fix it, you need set alpha channel imagecolorallocatealpha to 127."

    Though I am not sure how to do it myself.

  5. kochfede
    Member
    Posted 5 years ago #

    Iam in the same way that you, but the problem its in the core or in the AJAX thumbnail generation?

  6. DougJoseph
    Member
    Posted 4 years ago #

    I am having the same issue. Does anyone have specific steps on how to put the above remedy in place?

  7. DougJoseph
    Member
    Posted 4 years ago #

    Is PHP GD part of WordPress? Or part of something outside WP? If it is something that I cannot touch without access to the web server, I don't think I can touch it. My site is hosted on godaddy.com

  8. DougJoseph
    Member
    Posted 4 years ago #

    Ester and Kochfede:

    I found some good news, at least as far as PNG files are concerned. I noticed something, had a hunch, and did some testing.

    If you use PNG instead of GIF, and make sure the PNG image (with transparency) is saved in 24-bit mode, when you upload it you will not see black backgrounds.

    The black background issue only affects images with transparency that are stored in less than 24 bits of color depth (i.e. 8-bit images).

    Since GIF format only allows a limited 8-bit color palette, the problem will regularly affect GIFs with transparency.

    However, PNG files can be stored in either 8-bit or 24-bit. (24-bit depth allows 8 bits for red channel, 8 bits for green channel, 8 bits for blue channel, and 8 bits for the transparency channel.)

    Use 24-bit PNG images and you will get to have both transparency and nice looking thumbnails.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.