Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End watermarking help

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #45273
    Pat130
    Member

    I have watermark a picture with a logo (a blue wolf logo in my code). I am trying to use a select form to position the wolf anywhere (top, right, or center) with the help of the php select form.

    My code is below
    // this tells the browser to render jpg image
    header(‘content-type: image/jpeg’);

    // getting the image name from GET variable
    $image = $_GET;

    // creating png image of watermark
    $watermark = imagecreatefrompng(‘watermark.png’);

    // getting dimensions of watermark image
    $watermark_width = imagesx($watermark);
    $watermark_height = imagesy($watermark);

    // creting jpg from original image
    $image_path = ‘http://localhost/water/sky_main.jpg’ . $image;
    $image = imagecreatefromjpeg($image_path);
    //something went wrong
    if ($image === false) {
    return false;
    }
    // getting the dimensions of original image
    $size = getimagesize($image_path);
    // placing the watermark 5px from bottom and right
    #x= $_POST;
    #y= $_POST;

    $dest_x = $size[0] – $watermark_width – $_POST;
    $dest_y = $size[1] – $watermark_height – $_POST;
    // blending the images together
    imagealphablending($image, true);
    imagealphablending($watermark, true);
    // creating the new image

    imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);
    imagejpeg($image);

    // destroying and freeing memory
    imagedestroy($image);
    imagedestroy($watermark);

    ?>

    #136742
    chrisburton
    Participant

    Why would you want to place a watermark overtop of an image through code?

    #136744
    Alen
    Participant

    > Why would you want to place a watermark overtop of an image through code?

    My thoughts exactly.

    The whole point of watermark is to make it harder for thieves to clone it out or to have some kind of identifiable branding.

    #136748
    unasAquila
    Participant

    Think deviantart, shutterstock or any image site. if you have users uploading images and you want to protect there images you would have to use code!

    #136749
    Alen
    Participant

    Right, but the watermark has to be on the image or it serves no purpose, since it can be removed.

    #136750
    unasAquila
    Participant

    Not using the gd libary as it creates a totally new image with the watermark.
    here is a [gist](https://gist.github.com/anonymous/5665539) of the above code so people can read it an maybe help.

    #136752
    Alen
    Participant

    > creates a totally new image with the watermark

    This, yes. Didn’t even read the code above, wasn’t formatted.

    #136753
    unasAquila
    Participant

    This [Gist](https://gist.github.com/anonymous/5665731) here works
    and usage assuming you name the file `watermark.php` and you have an image named `image.jpg`

    http://www.example.com/watermark.php?image=image.jpg&x=10&y=15

    if i’m missing something let me know.

    #136755
    Pat130
    Member

    Sorry guys, im new to this, I am just practicing. What i am trying to achieve is allowing users to change the watermarks position on the picture.

    #136798
    Pat130
    Member

    Never mind I solved it myself :) . I got what I wanted to achieved. Thank you people.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘Back End’ is closed to new topics and replies.