Jump to content


Photo
* * * * * 4 votes

Watermark


  • Please log in to reply
8 replies to this topic

#1 Xuxiix

Xuxiix

    Young Padawan

  • Members
  • Pip
  • 7 posts

Posted 13 March 2007 - 12:05 PM

First of, this is my first tutorial. So please, please, tell me what I can improve. Also, I don't really speak english. Although I'll do my best.

Edit: Forgot to tell, this require GD. Read more at http://php.net/gd

<?php
 
 /* (X) Tell the browser that this script, is a image. */
 header("Content-type: image/png");
 
 /* (U) Generate our watermark picture. */
 $Watermark = imagecreatefrompng("watermark.png");
 /* (X) Genererate our picture, where we want to put the watermark. */
 $Image = imagecreatefromjpeg("image.jpg");
 
 /* (I) Get the color at x: 0. y: 0. in our Watermark, and use that color, as the transparency color. */
 imagecolortransparent($Watermark,imagecolorat($Watermark,0,0));
 
 /*
 * (I) Merge the two images.
 * In english:
 * Get $Image and $Watermark, and put them together.
 * $PosX will return the right side of the image. And then substract 5px from it. So it isn't aligned to the right border.
 * $PosY will do the same. Except this is the y axis. And will go to the bottom. And then 5px away from it.
 * When you use both, it will return the corner. -5px of it. From both the bottom, and right side.
 * Note that a image start at x: 0. y: 0, in the upper left corner.
 * Set the size.x of $Watermark, and size.y too.
 * Transparent: 25
 */
 $PosX = imagesx($Image)-imagesx($Watermark)-5;
 $PosY = imagesy($Image)-imagesy($Watermark)-5;
 imagecopymerge($Image,$Watermark,$PosX,$PosY,0,0,imagesx($Watermark),imagesy($Watermark),25);
 
 /* (X) And then generate our new image, as a png. */
 imagepng($Image);
 
 ?>

That should be it!
If you have any questions. Feel free to ask me. I'll answer them! If I'm able to.

Edited by Xuxiix, 13 March 2007 - 02:15 PM.


#2 PhpFreak

PhpFreak

    Young Padawan

  • Members
  • Pip
  • 26 posts
  • Interests:Coding

Posted 18 March 2007 - 01:44 PM

Great first tutorial, keep it up.
Also, your English was perfect for me ;)

Edited by PhpFreak, 18 March 2007 - 01:44 PM.


#3 Xuxiix

Xuxiix

    Young Padawan

  • Members
  • Pip
  • 7 posts

Posted 21 March 2007 - 05:29 AM

Great first tutorial, keep it up.
Also, your English was perfect for me :wtf:


Thank you. :lol:

#4 Dat

Dat

    Young Padawan

  • Members
  • Pip
  • 55 posts
  • Gender:Male

Posted 23 August 2007 - 03:33 PM

Providing any screenshots would be helpful how things are suppose to turn out.

#5 Leibrockoli

Leibrockoli

    Young Padawan

  • Members
  • Pip
  • 27 posts

Posted 27 February 2008 - 05:43 PM

Link to an example file might help.

#6 krekas

krekas

    Young Padawan

  • Members
  • Pip
  • 11 posts
  • Gender:Male
  • Location:somewhere

Posted 28 February 2008 - 12:18 AM

Agree with Dar and Leibrockoli

#7 Smashe

Smashe

    Young Padawan

  • Members
  • Pip
  • 18 posts
  • Gender:Male
  • Location:England

Posted 16 June 2008 - 10:25 AM

That's quiet simple - nice one :lol:

#8 The-Pixel

The-Pixel

    Young Padawan

  • Members
  • Pip
  • 132 posts
  • Gender:Female
  • Location:Iowa
  • Interests:Web Design and Development

Posted 16 June 2008 - 01:34 PM

Great job.

#9 Mr.Shawn

Mr.Shawn

    Young Padawan

  • Members
  • Pip
  • 15 posts
  • Gender:Male
  • Location:London, Emirates Stadium

Posted 23 June 2008 - 01:38 AM

Looks interesting. Might give it a try.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users