somerfeld Posted December 29, 2006 Share Posted December 29, 2006 The purpose of the script is to re size a image and watermark it with another overlayed image which has also been resized to the same parimiters.I seem to be able to resize the images and overlay them,.however the watermark is not preserving the alpha layer.,.. Ive tried a few different items and have continously have had no resolvewhat is wrong with the following script.? thank you!Links to watermark 24bit png with transparency perserved filehttp://gateway-productions.com/v6/media/gallery/watermark.pngLink to the current output filehttp://gateway-productions.com/v6/media/gallery/error.jpgLink to what this function should be outputtinghttp://gateway-productions.com/v6/media/gallery/correct.jpg[code]<?//declare varibles$base = '/home/djgatewa/public_html/v6/media/gallery/';If (empty($type)){ $type='ws'; $root=$base.$page.'/'; $size=150; } else{ $root= $base.$cat.'/'; $size=600; }function makeimagefile($root,$image,$page,$size,$type,$base){//load images $wm = imagecreatefrompng($base.'watermark.png'); $im = imagecreatefromjpeg($root.$image);//get sizes $sz=$size; $im_width=imageSX($im); $im_height=imageSY($im); $wm_width=imageSX($wm); $wm_height=imageSY($wm);//perserve alpha of watermark imageAlphaBlending($wm, false); imageSaveAlpha($wm, true);// work out new sizesif($im_width >= $im_height){ $factor = $sz/$im_width; $im_new_width = $sz; $im_new_height = $im_height * $factor; $wfactor = $sz/$wm_width; $wm_new_width = $sz; $wm_new_height = $wm_height * $wfactor;}else{ $factor = $sz/$im_height; $im_new_height = $sz; $im_new_width = $im_width * $factor; $wfactor = $sz/$wm_height; $wm_new_height = $sz; $wm_new_width = $wm_width * $wfactor;}//find bottom middle placement for watermark $dest_x = ( ( $im_new_width - $wm_new_width ) / 2 ); $dest_y = $im_new_height- $wm_new_height ; //now make new image size is memory$new_wm=ImageCreateTrueColor($wm_new_width,$wm_new_height);$new_im=ImageCreateTrueColor($im_new_width,$im_new_height);//now copy image into new image in memory with images new sizesImageCopyResized($new_im,$im,0,0,0,0,$im_new_width,$im_new_height,$im_width,$im_height);ImageCopyResized($new_wm,$wm,0,0,0,0,$wm_new_width,$wm_new_height,$wm_width,$wm_height);//merge new image with new watermark at middle bottom with 80% transparencyImageCopyMerge ($new_im,$new_wm,$dest_x,$dest_y,0,0,$wm_new_width,$wm_new_height,80);//output and save final imageImagejpeg($new_im,$root.$type.'/'.$type.'_'.$image,75); // quality 75;//cleanup memoryImageDestroy($im);ImageDestroy($wm);ImageDestroy($new_im);ImageDestroy($new_wm);}?>[/code] Link to comment https://forums.phpfreaks.com/topic/32195-php-gd-alpha-transparency-problems-anyhelp/ Share on other sites More sharing options...
somerfeld Posted December 30, 2006 Author Share Posted December 30, 2006 anybody>? Link to comment https://forums.phpfreaks.com/topic/32195-php-gd-alpha-transparency-problems-anyhelp/#findComment-149757 Share on other sites More sharing options...
somerfeld Posted December 30, 2006 Author Share Posted December 30, 2006 ? Link to comment https://forums.phpfreaks.com/topic/32195-php-gd-alpha-transparency-problems-anyhelp/#findComment-149916 Share on other sites More sharing options...
michaellunsford Posted December 30, 2006 Share Posted December 30, 2006 I haven't read your script, however, I have seen this problem before. The best thing I can suggest is to resize your original image to match (or as close as you can get) your watermark image. Apply the watermark and then resize again (if necessary).Why? Who knows. All I know is GD doesn't seem to like resizing (or rotating) an image with alpha.hope that helps. Link to comment https://forums.phpfreaks.com/topic/32195-php-gd-alpha-transparency-problems-anyhelp/#findComment-149925 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.