Hi, I like to accomplish the following: I have a members sections with pictures and to prevent the people to publish the pictures I like to watermark them on the fly with their username using a somewhat transparent approach to the text so it is not completely disturbing.
I searched here and I searched google but it seems I cannot find any working solution to this. I would not like to create transparent pngs for all letters capital and small and all numbers to place images on the picture.
Is there any way, I can accomplish to place semi-transparent Text on an image just using gd funtions?
Watermarking Images with transparent text
Moderator: General Moderators
Re: Watermarking Images with transparent text
Got it myself. Just my solution for future reverence:
Now I will add a custom Font and all is fine 
Code: Select all
$text = "Some Text";
$the_image = imagecreatefromjpeg("path_to_pic");
$stamp = imagecreatetruecolor(260, 18);
imagesavealpha($stamp, true);
$white = imagecolorallocate($stamp, 255, 255, 255);
$grey = imagecolorallocate($stamp, 128, 128, 128);
$black = imagecolorallocate($stamp, 0, 0, 0);
$trans_colour = imagecolortransparent($stamp, $white);
imagefill($stamp, 0, 0, $trans_colour);
imagestring($stamp, 5, 0, 0, $text, $grey);
$marge_right = 0;
$marge_bottom = 0;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
imagecopymerge($the_image, $stamp, imagesx($the_image) - $sx - $marge_right, imagesy($the_image) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 60);