domain

PHP: How To Create Copyright Watermark On Your Images

This is happen 3 days ago when my friend asking for converting him .htaccess into lighttpd rewrite rules format. After conversion done he wanted to share this script to everyone. If you’re professional Fotographer or just blogger, you may wanted to copyright all your photos/images. Even we know, sometimes people like to share for having fun…. but some people need a copyright to protected his original works before someone copy it. If you’re doing this manually it will take a long time and of course you will bored before this done. In short time we can make a simple watermark to protected our images.

Requirements:

  1. Apache with mod_rewrite / lighttpd (just convert rewrite rules, it should work)
  2. PHP with GD library (check in your phpconfig or asking your webhosting)

Step one.

Prepare one images that you should used as watermark.  This images should be in .PNG format, you can created one using photoshop software to make transparant effect.

Step two.

Make new or open your .htaccess files and write down this code inside it:

RewriteEngine On
RewriteRule ^(.+)\.jpg$ wrapper.php?image=$1\.jpg [L]
RewriteRule ^(.+)\.gif$ wrapper.php?image=$1\.gif [L]
RewriteRule ^(.+)\.png$ wrapper.php?image=$1\.png [L]
RewriteRule ^(.+)\.bmp$ wrapper.php?image=$1\.bmp [L]

For Lighttpd users try to using this conversion, if you meet any problem just following your path and symbol :

url.rewrite-once = (
“^\(.*).jpg” => “/wrapper.php?image=$1.jpg”,
“^\(.*).gif” => “/wrapper.php?image=$1.gif”,
“^\(.*).png” => “/wrapper.php?image=$1.png”,
“^\(.*).bmp” => “/wrapper.php?image=$1.bmp”
)

Step three.

Create wrapper.php files and put code below inside it:

<?php
$watermark = “watermark.png”;
$image = $_GET[“image”];

if (empty($image)) die();

if (!file_exists($image)) {
header(“404 Not Found”);
echo “File Not Found.”; die();
}
Read More »PHP: How To Create Copyright Watermark On Your Images