Can it preserve PNG transparency.

Started by Hylland, August 04, 2011, 10:22:08 PM

Hylland

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.

zubrag

Unfortunately, i do not have php installed currently so can't test, but maybe following will work.

In image.class.php replace this
    // 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
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);
}

Hylland

Just tried it out and it worked the first time. Thanks again.

JustinDonnel

Why do you guys use code to do it instead of tools to easier have it done?

jason1adkins

why the hell you guys are using these scripts while you can use tools instead  :-\