Joomla Extensions Demo

Support

Do not submit a bug report if you need technical support or have questions.

Forums

Post your suggestions ask for help in the community forums

Contact Me

Missing images/links, any comments, suggestions, need help? Contact me

Skype

Need desperately help?
Skype Me™! But dont abuse of it!

Digital watermarking with PHP and GD2

joomla_cms

php.logo  

Digital watermarking is the process of possibly irreversibly embedding information into a digital signal. The signal may be audio, pictures or video, for example. If the signal is copied, then the information is also carried in the copy. In visible watermarking, the information is visible in the picture or video. Typically, the information is text or a logo which identifies the owner of the media. [Wikipedia]

If you decide to go with an online watermarking, you can let watermark picture on the fly using php and .htaccess (at the cost of additional CPU server resources).

Why Watermarking pictures?

There is a lot of reasons, among others:

  • To limit images stealing, advanced users will still be able to crop/blur your watermark through!
  • To drive more new users/returning visitors to your site, anybody using your images in a forums may want to visit your site if the watermark can be read (don’t use complex logo, except if you have a well known brand)
  • To advertise your online work,

This article is a follow up of a previous article presenting how to watermark picture offline (definitive watermarking) using ImageMagick bash script. A lot of steps described there still apply

Features

  • Watermark pictures on the fly as soon as they are bigger than 500 pixels in width (PHP)
  • Watermark all or only pictures that are hot linked from outside your blog, for example in forums, other blogs (.htaccess setting)
  • Don’t watermark pictures hot linked from search images engine: Google images search or other (.htaccess setting)
  • Easily extensible to your needs: support multiple watermark pictures based on original image size.

Installation

create a file .htaccess with the following content, I recommend you to save it at the root of Joomla!® directory structure, you can merge this file with the one provided by Joomla!

# Uncomment next line to avoid that watermark apply on your
# site, replace yoursite.com with you Joomla! base
#rewritecond %{http_referer} !^
http://([^.]*[.]*)?yoursite.com/ [nc]

# Uncomment next line to avoid applying watermark in Google images
# search, copy as many lines as needed if you would like to also add Bing, Yahoo, etc...
#rewritecond %{http_referer} !^
http://(www.)?google.com/ [nc]


RewriteCond %{REQUEST_FILENAME} –f

# Path to the watermark.php script, and list of supported images
RewriteRule \.(gif|jpeg|jpg|png)$ /images/watermark.php [QSA,NC]

watermark.php script

Save this script into Joomla!® /images directory, under /images/watermark.php

Decide at which size you want to protect your images, here starting at 500pixels width, I will apply a watermark overlay in the left corner of the image.

<?php 
  $path = $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI']; 
  $image = imagecreatefromstring(file_get_contents($path)); 
  $w = imagesx($image); 
  if ($w > 500) { 
    $h = imagesy($image); 
    $watermark = imagecreatefrompng('watermark.png'); 
    $ww = imagesx($watermark); 
    $wh = imagesy($watermark); 
    imagecopy($image, $watermark, $w-$ww, $h-$wh, 0, 0, $ww, $wh); 
  } 
  header('Content-type: image/jpeg'); 
  imagejpeg($image); 
  exit(); 
?>

Caveats

It cost CPU and depending how you set your .htaccess may still allow users to steal images without watermark.

You might also like:
Alternate method to install Joomla/Drupal on Synology NAS
192 days ago
Alternate method to install Joomla/Drupal on Synology NAS
If you want more control, want to install Joomla yourself or want to install any other CMS, you ma
Running Joomla! on Synology NAS
192 days ago
Running Joomla! on Synology NAS
From small-and-medium business to individual users, Synology products offer a full range of choice
How to Solve a Problem with Joomla! jos_session
862 days ago
How to Solve a Problem with Joomla! jos_session
I was not seeing this error since at least 3 years: DB function failed with error number 1016
Watermarking your images with ImageMagick
951 days ago
Watermarking your images with ImageMagick
Digital watermarking is the process of possibly irreversibly embedding information into a digital
Joomlacomment 4.0 jQuery optimization
961 days ago
Joomlacomment 4.0 jQuery optimization
I did install yesterday evening the latest version of !JoomlaComment !JoomlaComment is one of th
Optimize Joomla! site
967 days ago
Optimize Joomla! site
I did optimize a bit my Joomla! homepage in the last few days. This has been achieved with Enab
Joomla! php, FastCGI, blank page and duplicate header 'Statu
1185 days ago
Joomla! php, FastCGI, blank page and duplicate header 'Statu
Since months, now I (understand also YOU) receive some blank page when browsing my Internet homepa
Skype me button for Joomla!
1191 days ago
Skype me button for Joomla!
Thanks to Skype web integration, making a button to show your online status has never been so easi
blog comments powered by Disqus
Category: How To

Donations

Thank You for supporting my work
Subscribe to me on YouTube

Latest Articles

  • In this series of post I will outline some common techniques to help Joomla extensions development. As you know Jooml... ...
  • CedTag  has been updated to version 2.5.3 and correct a lot of bugs and contains some nice features. CedTag is t... ...
  • CedThumbnails has been updated to version 2.5.5 and contains 1 new features for both Joomla 1.7 and Joomla 2.5. For ex... ...
  • CedSmugmug  has been updated to version 2.5.2 and correct some bugs and contains some nice features. CedSmugmug&... ...
  • If you want an extra gigabyte of storage on your Dropbox account, the online cloud service invites you to compete in i... ...

Subscribe

Latest Comments

Popular Posts

rockettheme advertisement

dropbox logo

Help Us & Leave Feedback!

  • Do you have an excellent article idea you would like to read about here? Share it!
  • Do you have some interesting tips how we could improve our site?
  • Something missing here? Help us make this blog a better place, leave feedback!
We would love to hear from you! Be active! Write us now!