$mw || $oh > $mh ) { if( $ow > $oh ) { $tnw = $mw; $tnh = $tnw * $oh / $ow; } else { $tnh = $mh; $tnw = $tnh * $ow / $oh; } } else { // although within size restriction, we still do the copy/resize process // which can make an animated GIF still $tnw = $ow; $tnh = $oh; } $imtn = imagecreatetruecolor( $tnw, $tnh ); $originaltransparentcolor = imagecolortransparent( $image ); if( $originaltransparentcolor >= 0 // -1 for opaque image && $originaltransparentcolor < imagecolorstotal( $image ) ) { $transparentcolor = imagecolorsforindex( $image, $originaltransparentcolor ); $newtransparentcolor = imagecolorallocate( $imtn, $transparentcolor['red'], $transparentcolor['green'], $transparentcolor['blue'] ); imagefill( $imtn, 0, 0, $newtransparentcolor ); // assign the transparent color in the thumbnail image imagecolortransparent( $imtn, $newtransparentcolor ); } // copy/resize as usual imagecopyresized( $imtn, $image, 0, 0, 0, 0, $tnw, $tnh, $ow, $oh ); $image = $imtn; //imagegif( $imtn, 'test.thumbnail.gif' ); //imagedestroy( $image); //imagedestroy( $imtn ); # $insert = imagecreatefrompng("logo-gross.png"); $insert = imagecreatefrompng("img/logo.png"); $image = image_overlap($image, $insert); function image_overlap($background, $foreground){ $insertWidth = imagesx($foreground); $insertHeight = imagesy($foreground); $imageWidth = imagesx($background); $imageHeight = imagesy($background); $overlapX = $imageWidth-$insertWidth-5; $overlapY = $imageHeight-$insertHeight-5; $overlapX=0; $overlapY=$imageHeight-$insertHeight-5;; //imagecolortransparent($foreground,imagecolorat($foreground,0,0)); imagealphablending($background, 1); imagealphablending($foreground, 1); imagecopy($background,$foreground,$overlapX,$overlapY,0,0,$insertWidth,$insertHeight); //imagecopymerge($background,$foreground,$overlapX,$overlapY,0,0,$insertWidth,$insertHeight,80); return $background; } imagepng($image); imagedestroy($image); ?>