Add logo in the bottom of image when uploaded in server

4 replies
I have a photo sharing website where users upload their pics. I want to add a logo of my website below the image and make it a part of the image when it is uploaded in the server so that whenever the image gets downloaded from the server, it will show the image and my logo at the bottom. Many sites use this technique. How to do this?
Thanks in advance.
#add #bottom #image #logo #server #uploaded
  • Profile picture of the author Bruce Hearder
    Hi devaldcool,

    What you want is "WaterMarking". This is done either at upload time, but more commonly just before the image is displayed.

    Your servers needs to have graphics installed, so if its a PHP site, you will need to check to see that PHP has been compiled with the GD library.

    You can do that by making a simple 1 line php program that looks like this:

    <?php phpinfo(); ?>

    Put this on your server and then run it.
    If you see GD referenced in the results, then you are good to go. Otherwise you may have top contact your hosting company and get them to recompile PHP with the GD library.

    The following PHP code snippet may help you get things rolling:

    <?
    // Load the stamp and the photo to apply the watermark to
    $stamp = imagecreatefrompng('stamp.png');
    $im = imagecreatefromjpeg('photo.jpeg');

    // 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);

    ?>

    I must give credit to [URLhttp://stackoverflow.com/questions/2235152/add-watermark-to-images-with-php]XUE Can[/URL], as he wrote the snippet and I just "borrowed" it..

    I hope this helps you out..

    Bruce
    {{ DiscussionBoard.errors[7704307].message }}
    • Profile picture of the author devaldcool
      Originally Posted by Bruce Hearder View Post

      Hi devaldcool,

      What you want is "WaterMarking"......I hope this helps you out..

      Bruce
      Thank you Bruce, for your help. I was seacrhing for this for about 6 hours but could not find it. Thanks...


      I also want to ask that when I want to display the image on my website, I do not want to display the logo. But when it gets downloaded, it displays the logo.
      {{ DiscussionBoard.errors[7704448].message }}
      • Profile picture of the author Brandon Tanner
        Like Bruce mentioned, the GD library can do this. Also, Image Magick is another good option...

        http://www.imagemagick.org/Usage/annotating/
        Signature

        {{ DiscussionBoard.errors[7704510].message }}
      • Profile picture of the author Bruce Hearder
        Originally Posted by devaldcool View Post

        I also want to ask that when I want to display the image on my website, I do not want to display the logo. But when it gets downloaded, it displays the logo.
        Its impossible to tell the difference between someone downloading an image and viewing an image inside a web page.

        best to watermark everything, with something that is subtle but distinctive..

        Hope that helps..

        Bruce
        {{ DiscussionBoard.errors[7707094].message }}

Trending Topics