I wrote a collection program to add watermarks to images. online images are collected with a bunch of garbled characters.
Header ("Content-type: image/jpeg; charset = utf-8"); then the normal image is displayed
Now I want to add a watermark to the image.
I saved the collected images directly to the directory and then loaded them as follows:
$ Fp = @ imagecreatefromjpeg (image path );
$ Wp = @ imagecreatefrompng (Watermark path );
$ Res = imagecopy ($ fp, $ wp, 0,120,180, 0 );
Imagejpeg ($ fp );
Now I want to add a watermark directly to the directory without saving it. how can this problem be solved? please kindly advise. thank you!
Reply to discussion (solution)
I don't understand. do you have to store your data somewhere?
The imagecreatefromjpeg () function of php supports the rfc2397 standard. you can use
$ Mime = 'image mime type, such as image/png, image/jpeg '; $ base64_content = base64_encode ('image content'); $ uri = "data: {$ mime }; base64, {$ base64_content} "; $ fp = @ imagecreatefromjpeg ($ uri );
Or you can save the image to a temporary folder, which is more convenient.
Program on SAE and BAE
It is relatively difficult to save images and drop them into storage.
Besides, I do not want to save images.
So you can ask if you can directly add the watermark output without saving it.
Isn't there imagecreatefromstring?
$fp = imagecreatefromstring(file_get_contents('http://avatar.profile.csdn.net/9/D/6/1_dream1206.jpg'));$wp = imagecreatefromstring(file_get_contents('http://avatar.profile.csdn.net/1/5/6/1_gilper.jpg'));imagecopymerge($fp,$wp,0,0, 0, 0,120,180, 50);imagepng($fp);
Previously, we have studied how to use imagemagick to add watermarks with powerful functions. You can see
The forum is very good. I understand a lot.
Isn't there imagecreatefromstring? PHP code? 1234 $ fp = imagecreatefromstring (file_get_contents ('http: // batch); $ wp = imagecreatefromstring (file_get_conten ......
Thank you very much. we have done this. we have not found this function before.
First, ask a question. use
Header ("Content-Type: image/jpeg ");
Imagejpeg ($ fp );
In this way, the file has been declared as an image and cannot be directly associated with the original HTML. how can we directly echo the image somewhere in HTML?
I know that I can't use the img label to load another webpage. please refer to other methods. thank you.
You can use iframe or css as the background without img.
You can use iframe or css as the background without img.
In special cases, you can only output data on this page.