corillo181 Posted February 24, 2008 Share Posted February 24, 2008 i took this code of a site, becuase i'm a rush to create a water mark, but as simple as it looks when the images is save, it saves as resource id# <?php $watermark = imagecreatefrompng('logo2.png'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg('eaa02aa217e7c72264582687e25183cb.jpg'); $size = getimagesize('eaa02aa217e7c72264582687e25183cb.jpg'); $dest_x = $size[0] - $watermark_width - 5; $dest_y = $size[1] - $watermark_height - 5; imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); imagejpeg($image,'new_'.$image,100); //imagedestroy($image); //imagedestroy($watermark); ?> Quote Link to comment Share on other sites More sharing options...
Bauer418 Posted February 24, 2008 Share Posted February 24, 2008 You are saving the file name as the image resource on this line: imagejpeg($image,'new_'.$image,100); Quote Link to comment Share on other sites More sharing options...
schilly Posted February 24, 2008 Share Posted February 24, 2008 you need to open a new file and add that resource into the imagejpeg line imagejpeg($image_resource,$file_resource,$quality); Quote Link to comment Share on other sites More sharing options...
corillo181 Posted February 24, 2008 Author Share Posted February 24, 2008 alright i changed it a name but now the png that is been applied to the image does no contain it's transparency it turns white. <?php $watermark = imagecreatefrompng('logofotos.png'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg('e47ade7dacd19dce6251270cd5f5e83c.jpg'); $size = getimagesize('e47ade7dacd19dce6251270cd5f5e83c.jpg'); $dest_x = $size[0] - $watermark_width - 5; $dest_y = $size[1] - $watermark_height - 5; imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); imagejpeg($image,'new_image.jpg',100); //imagedestroy($image); //imagedestroy($watermark); ?> Quote Link to comment Share on other sites More sharing options...
corillo181 Posted February 25, 2008 Author Share Posted February 25, 2008 so no help here? Quote Link to comment Share on other sites More sharing options...
DarkerAngel Posted February 25, 2008 Share Posted February 25, 2008 You usage of imagecopymerge is redundant try just using imagecopy($image, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height); see if that preserves the alpha values Quote Link to comment Share on other sites More sharing options...
corillo181 Posted February 25, 2008 Author Share Posted February 25, 2008 that works, thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.