Say NO to image theft

One of many things bloggers are afraid from, is that other people can steal images from your website, I have to say that there is no way to prevent it for all, but those ideas will make it more difficult.

burglar

There are three solutions posted here : one is a PHP code and, second is a code to put in your .htaccess file and the third one is a wordpress plugin. The PHP solution is to prevent users  from using the right click button and make it difficult to download it from your blog or to find the picture link in the source code.

1- PHP code :
Use this first in your CSS file :

.image	           { position:relative; overflow:hidden; }
.pixel		{ width:1px; height:1px; position:absolute; }
#pixels .pixel {float:left; position:relative; width:1px; height:1px;}

After that use this code in your pages :

// settings
$image = 'ImageName.png';

// get the image size
list($width,$height) = getimagesize($image);
$img = imagecreatefrompng($image);

// data array
$data = array('height'=>$height,'width'=>$width,'pixels'=>array());

// start the height loop
for ($y = 0; $y < $height; $y++){
	for ($x = 0; $x < $width; $x++)
       {
                $color_index = imagecolorat($img, $x, $y);
 		$a = ($color_index & 0x7F000000) >> 24;
		$r = ($color_index >> 16) & 0xFF;
		$g = ($color_index >> 8 ) & 0xFF;
		$b = $color_index & 0xFF;
		if ($a > 0){
			$a = abs(($a / 127) - 1);
			$a = hex(round($a * 255));
		} else {
			$a = '';
		}
		$r = hex($r);
		$g = hex($g);
		$b = hex($b);
		$data['pixels'][] = "$r$g$b$a";
	}
}

// clean up
imagedestroy($img);

/* utility function */
function hex($v){
	$bit = dechex($v);
	if (strlen($bit) == 1) $bit = "0$bit";
	return $bit;
}

2- .htaccess file :

The second way is when you like to stop hotlinkers, just put those lines in your .htaccess file, Hotlink protection can save you lots of bandwidth by preventing other websites from displaying your images or pictures  :

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain1.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain2.com [NC]
RewriteRule .(gif|jpg|jpeg|png)$  http://www.yourdomain/pic.jpg  [R,L]

The 4th line is optional, you should use is it if you want to allow an other website to show you images. You can add as many websites as you want by adding the same line.

http://www.yourdomain/pic.jpg : The url to a replacement image.

erreur

3- A wordpress plugin :

The plugin called : Distilled Hotlink Builder and you can download it from the wordpress extend page.

This plugin uses a hidden message in a div layer and display it when the users right clicks the image.

You May Also Like

Relevant tips in picking your blog’s name

    When it comes to picking a blog name, there are certain rules that you will have to consider: Create a name that indicates your blog focus- Most online users check the link first before going directly to a blog especially when they are using a search engine. Hence, you will need a relevant […]

6 Easy Steps To Follow After Your Guest Post Is Published

Writing and get your guest article published is a very strenuous job as it requires long work hours, reading blogs, studying your audience, choosing the right topic and a million other things, but once you get it published you deserve appreciation. The main purpose of a guest post is to get traffic and subscribers to […]

Working With Designers: Tips for a Successful Collaboration

Now that the competition between businesses keeps on getting higher and higher, you need to get a grip and equip your company with talented individuals. If you have a team of designers that can ensure well-designed and consistent visuals for your brand, you can be steps ahead of your competitors. Collaborating with designers can benefit […]

5 Easy ways to get started with SEO: Build-up traffic in just one month!

In just one month, you’ll be able to drive the keywords to your site through the help of these 5 easy SEO ways. Firstly, you have to prepare your site and put your efforts on it. Announcing your blog to the world is certainly a big step however you have to prepare your blog have […]