About adding a watermark to a picture

Source: Internet
Author: User
Tags imagejpeg
I wrote a collection program to collect the pictures on the internet and get back a bunch of garbled characters.
Header ("Content-type:image/jpeg;charset=utf-8"), after which the normal picture can be displayed
Now I want to add a watermark to the picture.
I saved the captured picture directly to the directory and then loaded it as follows
$fp = @imagecreatefromjpeg (picture path);
$WP = @imagecreatefrompng (watermark path);
$res = Imagecopy ($fp, $wp, 0, 0, 0, 0,120,180);
Imagejpeg ($FP);
Now I want to not save to the directory directly with the watermark on the page to show what to do please give us your advice.


Reply to discussion (solution)

Don't quite understand, your data must have a place to keep?
PHP's Imagecreatefromjpeg () function supports the rfc2397 standard, which you can use

$mime = ' picture MIME type, such as image/png, Image/jpeg '; $base 64_content = Base64_encode (' picture content '); $uri = "data:{$mime};base64,{$ Base64_content} "; $fp = @imagecreatefromjpeg ($uri);

Or you can save the picture to a temporary folder, which is more convenient.

The program is on SAE and BAE.
Save the picture to throw into the storage relatively trouble
And I don't really want to save the picture
So to ask if you can directly add watermark output, without saving

Isn't there a 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, imagepng ($FP);

Previously studied with ImageMagick watermark, the function is more powerful. Landlord can see

The forum is very good and very good understand a lot

Isn't there a imagecreatefromstring? PHP code?1234$fp = imagecreatefromstring (file_get_contents (' http://avatar.profile.csdn.net/9/D/6/1_dream1206.jpg ' ); $wp = Imagecreatefromstring (File_get_conten ...

Thank you so much, we've done it, and I haven't seen this function before.
Ask a question first, with
Header ("Content-type:image/jpeg");
Imagejpeg ($FP);
This way has already declared the file as a picture, not directly with the original HTML together, how to directly echo out of the picture in the HTML somewhere?
Write a separate Web page with an IMG tag. I know, but this is not the right time to use this, please consult other methods, thank you.

You can use an IFRAME without IMG, and you can also use CSS as a backdrop.

You can use an IFRAME without IMG, and you can also use CSS as a backdrop.
The situation is more special only on this page output no way to temporarily this bar 3Q

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.