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

Helpful Tips in trying out your own blog and making improvements

Test-running your own blogs helps a lot to improve your own blog site. First time bloggers have difficulty in running their blogs the way they wanted it to be. Nonetheless, your first days of blogging are not the only time to test-run your blog. You can test-run your blog whenever you have new additions like […]

Easy Ways to Protect your Vision when Blogging for hours

If you work online as a blogger you must be spending a lot of time in front of the computer. Eventually, you will notice that you are getting problems with your visions. You can ignore it for a moment but it can cause you serious problems in the long run. How will you be able […]

Five Health Tips Every Blogger Shouldn’t Ignore

If you are a blogger or a freelancer, it means that your work on your computer all the day long, you may unconsciously be setting your body up for a number of health problems. But to keep yourself in a good shape, listed here six body parts that any computer user should focus on: 1- […]

Business Blogging: 5 Tactics to Improve Your Small Business’ Online Presence

If you’re a small business owner, you know that having a strong online presence is crucial to your success. But did you know that business blogging can be an incredibly effective way to improve your online visibility and increase your conversion rates? Check out several tactics that can help you maximize the potential of your […]