Zubrag.com :: Forum

zubrag.com => Thumbnail Generator => Topic started by: Hylland on August 04, 2011, 01:22:08 PM



Title: Can it preserve PNG transparency.
Post by: Hylland on August 04, 2011, 01:22:08 PM
Love the script, but it doesn't seem to keep the alpha channel of the original (also PNG). Is there somewhere i can change a property or something to preserve this? This would make it alot more usable to me. Let me just say "thanks" ahead of time for any help you can give me. I'm more of an actionscripter than a php guy so I'm not familier with the correct methods.


Title: Re: Can it preserve PNG transparency.
Post by: zubrag on August 06, 2011, 09:05:07 AM
Unfortunately, i do not have php installed currently so can't test, but maybe following will work.

In image.class.php replace this
Code:
    // Copy and resize part of an image with resampling
    imagecopyresampled(
      $ni, $im,             // destination, source
      0, 0, 0, 0,           // dstX, dstY, srcX, srcY
      $this->max_x, $this->max_y,       // dstW, dstH
      $orig_x, $orig_y);    // srcW, srcH

with this
Code:
if ($orig_img_type == 3) {
    imagealphablending($ni, false);
}

    // Copy and resize part of an image with resampling
    imagecopyresampled(
      $ni, $im,             // destination, source
      0, 0, 0, 0,           // dstX, dstY, srcX, srcY
      $this->max_x, $this->max_y,       // dstW, dstH
      $orig_x, $orig_y);    // srcW, srcH
 
if ($orig_img_type == 3) {
    imagesavealpha($ni, true);
}


Title: Re: Can it preserve PNG transparency.
Post by: Hylland on August 06, 2011, 03:38:03 PM
Just tried it out and it worked the first time. Thanks again.


Title: Re: Can it preserve PNG transparency.
Post by: JustinDonnel on April 01, 2016, 06:16:52 AM
Why do you guys use code to do it instead of tools to easier have it done?


Title: Re: Can it preserve PNG transparency.
Post by: jason1adkins on April 25, 2019, 05:08:33 AM
why the hell you guys are using these scripts while you can use tools instead  :-\