hi,
how do you call the watermarked image inside a html file?
let's say i have a "/folder/image.jpg" image and i want to display it in my page.html
please help.thanks
Printable View
hi,
how do you call the watermarked image inside a html file?
let's say i have a "/folder/image.jpg" image and i want to display it in my page.html
please help.thanks
From what's been described here, this is no better (in fact, it might be worse) than just opening the image in Photoshop, dropping the watermark PNG on top, and resaving the image.
How is it dynamic if you have to hard-code the SRC? And if you can build the SRC into the code, how do you call this PHP file from another file? Since it obviously has to be its own PHP file, based on the need for HEADER at the top of the file?
Sorry, I'm just not sure how you use this script at all.
Hi Jason,
Images are dynamically generated/altered with PHP all of the time. You call them as image files directly like you would reference any image in a PHP page:
You can pass the source (or, to be safer, some database row ID that will reference the source) to the PHP script just like any other script with either a query string or a file string that mod_rewrite will break down into a query string.Code:<img src="/path/to/php/file.php" alt="dynamic image" />
I know you are obviously very new to PHP programming but, maybe show a bit more modesty when asking questions seeing as your own understanding is clearly at a very modest level.
P.S. This script is very old and, if I were to rewrite, there would be many changes to it such as image caching, image resizing, multiple filetypes, etc.
Welcome to PHP and web development!
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefromjpeg($_GET['src']);
Not sure I understand this bit--you grab the result from imagecreatetruecolor, but before you do anything with it you stomp over it with the very next call. Mistake, or something subtle going on there?
Fantastic and very sleek!
Note for minor correction:
In "Merging the Image and the Watermark" this line needs a semicolon at the end or you'll get a syntax error unexpected T_STRING
Thank you!
Why wouldn't the watermark's alpha channel be dropped? It replaces it with white over the image... Thank you...
how do i suppose to use it lets say for SMF forum? :-/
You can add digital watermark by the watermark software picmarkrpro.com .
If yoh have an flickr account you can replace your Flickr photos with their watermarked copies.
Hi, I' am using your script and it works fine, but......
How do I create a png-8 file with transparency?
Hope to hear from you soon.....
Very helpful article. Help a lot. Thanks.
thanks for guiding through
but
this method destroys the watermark image alpha transparency on the final image
imagealphablending($d_img, false);
$color = imagecolorallocatealpha($d_img, 0, 0, 0, 127);
imagefill($d_img, 0, 0, $color);
imagesavealpha($d_img, true);
imagecopyresampled($d_img,$s_img,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h);
will preserve the watermark image transparency in the gd memory.
Thanks for a great article. It was just what I needed.