Watermarking PNG and JPEG Images with PHP and GD2

Have you ever wanted to add a transparent watermark to an image that you post on your website? If so, then this may be exactly what you are looking for!

Choose the image to watermark, the watermark you want to use (pulled from a directory of images), how you want it positioned on the resulting image and its size. Watermarked images are stored on the server so you can use them later. Management screen also lets you delete a watermarked image from the server to reduce clutter.

A BIG "Thank-you" goes out to J Wynia for his excellent article entitled "Watermarking Photos with PHP/GD2" from June 3, 2003 that covers the basics that were used to get this system together!

Watermark A JPEG or PNG Image

View Previously Watermarked Images Source Code Download

If you are uploading a PNG-24 image that has alpha transparency and are saving it as a PNG, the transparency will be saved with the watermarked version of the image. However, if the original image is a PNG-8 with transparency, you may get unexpected results.

Image to WaterMark:

(72dpi, RGB JPEG/PNG)

Choose Watermark:

Watermark images are located in the "watermarks" subdirectory. All images are PNG-24 with alpha transparency. These images were created using Adobe Photoshop® by setting the image's opacity to 30% and using the "Save For Web" option to save the file.

The watermark images shown are not displayed at their true size, they are actually quite a bit larger so that the quality of the watermark will not deteriorate as quickly when watermarking larger images.

Watermark Position:

(Horizontal)

Left
Center
Right
Watermark Position:

(Vertical)

Top
Center
Bottom
Watermark Coverage:

(Size of Originial)

Entire Image Area
1/2
1/3
1/4
1/8
1/10
Save Result As: JPEG
PNG