• (I might have erroneously posted this to another forum, sorry for double posting)

    I am a big fan of NG Gallery and so far have used it with minimal, make that negligible, problems. However, a group of my students developed a WordPress site where they are presenting portfolio images in PNG format with transparent background. The images display with no problem at all. However, the transparency is being rendered as black background on the thumbnail images created by NG libraries.

    I have noticed quite a few inquiries about this problem with no resolution. I am writing once more to ask for assistance from the developer who has given us a wonderful tool to use. The problem seems to be related to libraries rather than the core of NG Gallery, so I am not sure if the plugin author will be inclined to provide a fix. I hope that there will be a clear, once and for all, reply to give the users some direction and what to expect.

    I am using a workaround of recreating the thumbnails off site and uploading over the NG generated thumbnails. It is a hack, but it works without giving the site an odd look.

    Please, Alex, give us some information as to where you stand on this problem.

    Thanks

    Cemal

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Cemal.
    I hope this code help you. You need to edit public_html/wp-content/plugins/nextgen-gallery/lib/gd.thumbnail.inc.php, comment native code of function fastimagecopyresampled and pun this code:

    function fastimagecopyresampled (&$dst_image, $src_image, `$dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h, $quality = 5) {
    $dst_img = imagecreatetruecolor($dst_w, $dst_h);
    imagealphablending($dst_image, false);
    imagesavealpha($dst_image,true);
    $transparent = imagecolorallocatealpha($dst_image, 255, 255, 255, 127);
    imagefilledrectangle($dst_image, 0, 0, $dst_w, $dst_h, $transparent);
    imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
    return true;
    }`

    After you must reset (clean) images cache in NG settings

    I tried pasting in the code, but is make thumbnail generation not working at all. Could someone maybe supply a working gd.thumbnail.inc.php file?

    Thanks!

    mmm it doesnt work for me too!

    Sorry guys, after updating and for me has ceased to work with an early posted function, now I use this code, can try:
    ` /**
    * Fast imagecopyresampled by [email protected]
    *
    */
    function fastimagecopyresampled (&$dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h, $quality = 3) {
    // Plug-and-Play fastimagecopyresampled function replaces much slower imagecopyresampled.
    // Just include this function and change all “imagecopyresampled” references to “fastimagecopyresampled”.
    // Typically from 30 to 60 times faster when reducing high resolution images down to thumbnail size using the default quality setting.
    // Author: Tim Eckel – Date: 12/17/04 – Project: FreeRingers.net – Freely distributable.
    //
    // Optional “quality” parameter (defaults is 3). Fractional values are allowed, for example 1.5.
    // 1 = Up to 600 times faster. Poor results, just uses imagecopyresized but removes black edges.
    // 2 = Up to 95 times faster. Images may appear too sharp, some people may prefer it.
    // 3 = Up to 60 times faster. Will give high quality smooth results very close to imagecopyresampled.
    // 4 = Up to 25 times faster. Almost identical to imagecopyresampled for most images.
    // 5 = No speedup. Just uses imagecopyresampled, highest quality but no advantage over imagecopyresampled.

    if (empty($src_image) || empty($dst_image)) { return false; }

    if ($quality <= 1) {
    $temp = imagecreatetruecolor ($dst_w + 1, $dst_h + 1);
    imagecopyresized ($temp, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w + 1, $dst_h + 1, $src_w, $src_h);
    imagecopyresized ($dst_image, $temp, 0, 0, 0, 0, $dst_w, $dst_h, $dst_w, $dst_h);
    imagedestroy ($temp);
    } elseif ($quality < 5 && (($dst_w * $quality) < $src_w || ($dst_h * $quality) < $src_h)) {
    $tmp_w = $dst_w * $quality;
    $tmp_h = $dst_h * $quality;
    // on whatever reason PHP 4.4.8 stopped here.
    $temp = imagecreatetruecolor ($tmp_w + 1, $tmp_h + 1);

    // *добавлено для прозрачности png*
    $dst_img = imagecreatetruecolor($dst_w, $dst_h);
    imagealphablending($dst_image, false);
    imagesavealpha($dst_image,true);
    $transparent = imagecolorallocatealpha($dst_image, 255, 255, 255, 127);
    imagefilledrectangle($dst_image, 0, 0, $dst_w, $dst_h, $transparent);
    //**
    imagecopyresized ($temp, $src_image, $dst_x * $quality, $dst_y * $quality, $src_x, $src_y, $tmp_w + 1, $tmp_h + 1, $src_w, $src_h);
    imagecopyresampled ($dst_image, $temp, 0, 0, 0, 0, $dst_w, $dst_h, $tmp_w, $tmp_h);
    imagedestroy ($temp);
    } else {
    //*добавлено для прозрачности png*
    $dst_img = imagecreatetruecolor($dst_w, $dst_h);
    imagealphablending($dst_image, false);
    imagesavealpha($dst_image,true);
    $transparent = imagecolorallocatealpha($dst_image, 255, 255, 255, 127);
    imagefilledrectangle($dst_image, 0, 0, $dst_w, $dst_h, $transparent);
    //**
    imagecopyresampled($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
    }
    return true;
    }`

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: NextGEN Gallery] PNG Thumbnails with transparancy problem’ is closed to new replies.