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); ?> Link to comment https://forums.phpfreaks.com/topic/92764-water-mark-trouble/ 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); Link to comment https://forums.phpfreaks.com/topic/92764-water-mark-trouble/#findComment-475287 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); Link to comment https://forums.phpfreaks.com/topic/92764-water-mark-trouble/#findComment-475299 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); ?> Link to comment https://forums.phpfreaks.com/topic/92764-water-mark-trouble/#findComment-475322 Share on other sites More sharing options...
corillo181 Posted February 25, 2008 Author Share Posted February 25, 2008 so no help here? Link to comment https://forums.phpfreaks.com/topic/92764-water-mark-trouble/#findComment-476226 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 Link to comment https://forums.phpfreaks.com/topic/92764-water-mark-trouble/#findComment-476247 Share on other sites More sharing options...
corillo181 Posted February 25, 2008 Author Share Posted February 25, 2008 that works, thank you. Link to comment https://forums.phpfreaks.com/topic/92764-water-mark-trouble/#findComment-476276 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.