To prevent quality images being stolen, we can use PHP to watermark web-images in popular formats like GIF/PNG/JPEG. We print a transparent gif-image on a jpeg-photo in this tutorial. For best results I prefer gif than png, because some png formats require extra functions to print a transparent image. We can convert this script to a batch-watermarker easily to watermark photo albums/galleries with multiple pictures by putting code in a loop or create a function.
Steps:
PHP functions:
imagecreatefromgif
imagecreatefromjpeg
getimagesize
imagecopymerge
header
imagejpeg
imagedestroy
Watermark image:
Main image:
Steps:
- Load both images
- Get size of both images
- Copy watermark to main image
- Print image to screen
PHP functions:
imagecreatefromgif
imagecreatefromjpeg
getimagesize
imagecopymerge
header
imagejpeg
imagedestroy
Watermark image:
Main image:
PHP Code:
Example images:
Watermarked image with 10% opacity
Watermarked image with 50% opacity
Watermarked image with 100% opacity
No comments:
Post a Comment