rifanece / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

PNG Transparency Not Maintained #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Resize a PNG with transparency and you'll get a white background.

Original issue reported on code.google.com by jjar...@gmail.com on 14 Apr 2008 at 7:53

GoogleCodeExporter commented 8 years ago
I'd like to fix this but I don't know how... if anyone has any better knowledge 
of GD
could step in and help it'd be most appreciated.

Original comment by BinaryMoon on 4 Sep 2008 at 11:12

GoogleCodeExporter commented 8 years ago
This can be resolved by modifying the following line
//---------------
    $image = open_image( $mime_type, $src );
//---------------

with

//---------------
if($mime_type=='png'){
$image = imagecreatefrompng($src); // open image
imagealphablending($image, true); // setting alpha blending on
imagesavealpha($image, true); // save alphablending setting (important)

}else
{
    $image = open_image( $mime_type, $src );
}
//---------------

Original comment by asifms...@gmail.com on 20 Sep 2008 at 1:01

GoogleCodeExporter commented 8 years ago
I can't get the PNG transparency to work with these changes. I still get black 
background where the alfa 
transparency is.

Original comment by kallewan...@gmail.com on 6 Mar 2009 at 8:43

GoogleCodeExporter commented 8 years ago

Original comment by BinaryMoon on 14 Mar 2009 at 10:30

GoogleCodeExporter commented 8 years ago
I also can't get the PNG transparency to work with these changes. I still get 
black background where the alfa 
transparency is.

Original comment by sav...@gmail.com on 20 Mar 2009 at 9:45

GoogleCodeExporter commented 8 years ago
I have tried the same and this does not appear to resolve the issue either --- 
it
should be noted though that the code for my timthumb script appears to have some
filtering of the type already -- maybe there is something not right with this.

CODE

// check to see if GD function exist
if(!function_exists('imagecreatetruecolor')) {
    $error = "GD Library Error: imagecreatetruecolor does not exist";
    die( $error );
}

if(strlen($src) && file_exists( $src ) ) {

    // open the existing image
    $image = open_image( $mime_type, $src );
    if( $image === false ) { die( 'Unable to open image : ' . $src ); }     

END CODE

Original comment by nathan%t...@gtempaccount.com on 17 Jun 2009 at 4:34

GoogleCodeExporter commented 8 years ago
Update for anyone else who finds this and can't figure out what's going wrong...
visit the Google Code site 
http://timthumb.googlecode.com/svn/trunk/timthumb.php and
download the latest version of timthumb and replace your existing file, this 
resolves
the transparency issues for me! Thanks to Darren for his pointing this out on 
the
thread
here:http://www.darrenhoyt.com/2008/04/02/timthumb-php-script-released/#comment-
19131

Original comment by nathan%t...@gtempaccount.com on 17 Jun 2009 at 4:55