Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

How do i make watermark to image using image URL ?

20142014 Member

How do i make watermark to image using image URL ?

Example - Check this link -
http://www.vatapita.com/hivtube.com/img-gen/index.php?source=http://i.imgur.com/t15trGU.jpg

Image Link - http://i.imgur.com/t15trGU.jpg

Script - http://www.vatapita.com/hivtube.com/img-gen/index.php?source=( My Image Link )

Comments

  • 20142014 Member

    How i make this script like above ? im a beginner :) Please tell me step by step..Please

  • perennateperennate Member, Host Rep
    edited August 2015
    1. Click the link
    2. Read the comments and adjust the code
    3. Do the thing
    4. Profit!
    Thanked by 1Jonchun
  • @2014 said:
    How i make this script like above ? im a beginner :) Please tell me step by step..Please

    Sure. I'll teach you step by step. $50/hour though. Please :)

  • hostnoobhostnoob Veteran
    edited August 2015
    <?php
    // Load the stamp and the photo to apply the watermark to
    $stamp = imagecreatefrompng('stamp.png');
    
    if (!filter_var($_GET['source'], FILTER_VALIDATE_URL))
    {
        exit('invalid source URL');
    }
    
    $source = file_get_contents($_GET['source']);
    $im = imagecreatefromstring($source);
    
    // Set the margins for the stamp and get the height/width of the stamp image
    $marge_right = 10;
    $marge_bottom = 10;
    $sx = imagesx($stamp);
    $sy = imagesy($stamp);
    
    // Copy the stamp image onto our photo using the margin offsets and the photo 
    // width to calculate positioning of the stamp. 
    imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
    
    // Output and free memory
    header('Content-type: image/png');
    imagepng($im);
    imagedestroy($im);
    ?>

    Of course, you want to amend $marge_right (amount of pixels from the right) and $marge_bottom (amount of pixels from the bottom) to adjust where the stamp is displayed on the page.

  • You can even make the watermark transluscent. Nice!

    http://php.net/manual/en/image.examples.merged-watermark.php

Sign In or Register to comment.