Zubrag.com
January 17, 2018, 02:59:14 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Can it preserve PNG transparency.  (Read 5939 times)
Hylland
Newbie
*
Posts: 2


« 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.

Logged
zubrag
Administrator
Hero Member
*****
Posts: 785


WWW
« Reply #1 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);
}
Logged
Hylland
Newbie
*
Posts: 2


« Reply #2 on: August 06, 2011, 03:38:03 PM »

Just tried it out and it worked the first time. Thanks again.
Logged
JustinDonnel
Newbie
*
Posts: 11


« Reply #3 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?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC