Image obfuscation - html

I have a web page wherein there is an image (background image of the page). I do not want the user to access the image directly by finding its location from the html source. How do I do that?
Also, I'm adding a barebone CSS for media= print. while doing a SAVE AS, I'm assuming the image will not be saved?
** I know there are ways to get the image if someone is really intent on it, but I want to make it difficult.
Edit:
I stumbled on this page - http://www.answerjam.com/privacy-policy - I would like to protect my image the same way they've done with their footer image.

There are a few different ways of protecting the image:
Use Javascript and override the right-click context menu (see this doc for a super easy way of doing it). However, all a user has to do is disable Javascript to get their hands on it.
Use a server-side language to check things like HTTP_REFERRER in your header and use a script to server the image (checking that field). Using a server-side language, you could also employ tricks like using GET parameters.
Having said all this, all that someone needs to do to get your image is use Firebug (or Chrome/Chromium) to check out the net tab to see downloaded content or visit their browser's cache. You could try to set your Cache-Control to no-cache when serving the image, but AFAIK, most browsers don't actually implement that for this purpose.
At the end of the day, trying to protect your images from anyone is much more of a headache than it's worth, when dealing with anyone but your grandmother visiting your site with IE6.

One way to do this that works well without JavaScript (so the site is still functional) is to use CSS to place a completely transparent PNG over the image you are protecting. If you try to right-click and save it, you'll end up saving the transparent image. The PNG can be a simple 1x1 image, and stretched to cover it.
<div class="imageContainer">
<img src="..." class="realImage" width="100" height="50"/>
<img src="/img/blank.png" class="blockImage" width="100" height="50"/>
</div>
CSS:
.imageContainer {
position: relative;
}
.imageContainer .blockImage {
position: absolute;
top: 0;
left: 0;
}
Of course, this still doesn't help at all if you have dev tools, but it eliminates right-click access without relying on JS or complicated tricks. It's also rather hard to get around without looking at the source.
You can combined this with the other examples.
It's still extremely easy to get around. I feel that needs to be restated a few dozen more times. Basic rule of internet content: if I can see it, I can copy it. (Like the "analog" hole - I can just screen-cap the browser.)

If you want to avoid standard visitors to see you're image directly, you can load it in javascript. Anyway, I assume that for visitors using firebug or any dev tool you just can't prevent it.
For example, to load your image with jQuery :
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('body').css('background-image', 'url(your_image.png)');
});
</script>

Related

Random images on 'refresh' in HTML without JavaScript

I once saw in a tutorial video about an HTML line of code that generates random images that it fetches from the internet and puts into the webpage, I remember it being a normal img tag but inside the ref attribute contained a link that now I don't remember what it was.
Searched about this in Google but all I could find was about loading images from the directory or using the help of Javascript.
This is possible by delegating the randomness to the server that serves the images. Consider the service provided by PlaceIMG. Setting any <img/> tag to one of their URLs will let your show a "random" image. What is actually happening is that the backend gets a request for an image and serves any image it wants.
You can do this with your own, self-hosted image server and in basically any server-side language and without client-side JavaScript. However, there has to be logic somewhere to do the randomness:
<img src="https://placeimg.com/640/480/any" />
There are many sites that serve as random image source, for example https://picsum.photos.
Working example (refresh to see the effect):
<img src="https://picsum.photos/200">

disable downloading of image from a html page

Suppose there is a html page containing some images.
we want to disable the downloading of the images from user side.
Is that possible?
Should I need to use any javascript or add some attributes in <img> tag?
My current code is
<td><img src="images/handmade (1).jpg" class="img-responsive" alt="" /></td>
</tr>
</table>
Is there any technique to prevent image from downloading?
No, it cannot be done. Explanation here: https://graphicdesign.stackexchange.com/a/39464/24086
For all intents and purposes, this is downright impossible.
You can disable right click, but people can still view the source code of your page (by adding view-source: to the URL in Chrome, or just using a browser menu) and find the URL.
You can use a CSS background-image instead of HTML , but people can still use their browser's inspector (F12 for most browsers) and find that element's CSS properties.
You can engineer some crazy thing that you think will work, but at the end of the day, the user has to download the image in some way to see it. If the user is completely unable to download the image, he/she won't even be able to see it in the first place! No matter what you do, nothing will prevent a simple glance at a network traffic monitor or the "Network" tab of your favorite browser's developer tools.
Depends what you mean by downloading, really.
The user has to be able to download the image (i.e. retrieve the image onto their computer) in order to display the image in their browser. I suspect what you mean is that you want to stop them saving that specific image onto their computer. Any attempt to try and stop them doing this is pretty pointless, as they can always take a screenshot, or just access the image directly using the URL.
I've seen various attempts using javascript to try and stop users from saving images, but they are all easily worked around.
Cut up the image server-side and store them that way, then assemble them as one image in javascript client-side. The user could download each segment via URL and assemble them manually, but that is much more work than most users are willing to do.

several images onclick maintain other images

So I am trying to find out a way to view images without hiding the rest when clicked on
for instance
<img src="someimage.jpg"/>
<img src="someimage2.jpg"/>
<img src="someimage3.jpg"/>
<img src="someimage4.jpg"/>
for instance when i click on the first image it opens up in a new window and thats it
i´d like to be able to scroll through these images. i´d like to be able to go to the next image by clicking "next" for instance or something like that!
Calling an image in the browser directly will return that file, not an html page with the file embedded. In your case you will have to write a page that handles this functionality for you.
You don't mention whether or not javascript / jquery is an option for you, but it would definitely be the easiest solution in my opinion.
Look into something like a jquery carousel to handle a basic slideshow.
And if this is not the answer you were looking for, then I'm afraid the solution for you - fitting your limits of html, css and image - is to make individual html pages for each image and hard code the next and previous links... each and every one... the good ol fashioned way.
... headers
<body>
<img src="someimage.jpg" alt=""><br>
Previous | Next
</body>
http://fancybox.net/ Has a great javascript type plugin for having the image show up in a type of lightbox. Otherwise seach for "jquery image zoom plugin". That should give you some good plugins if javascript will work for you.

Background image loading slowly

I have a site utilizing a background image that resizes to the window's size. This is achieved by placing an <img> in the body, and some custom CSS ( Technique #2 ).
I use a simple conditional statement in the header to determine which image to display:
<?php if (is_single(array(11,24,26,28,30,36))) : ?>
<img src="http://www.lookingglassstudio.ca/wp-content/uploads/2011/08/weddingsbg.jpg" class="bg" />
<?php else : ?>
<img src="http://www.lookingglassstudio.ca/wp-content/uploads/2011/08/stylingbg.jpg" class="bg" />
<?php endif; ?>
My problem is, the image reloads every time I refresh or navigate somewhere else. This results in a flash of white. See the website here!
I reckon the php script calls the image each time, resulting in the 'flash'.
Any way around this? Ways to make the image cache and not reload each time?
EDIT
I believe the issue is a FOUC problem. Will flash the background color (default white) when refreshed, causing flashes. FOUC fixes don't seem to help.
Issue occurs even with PHP conditional statement removed. Issue occurs when <img> is changed to background-image.
I noticed this question a while ago but hoped you'd get an answer that worked for you.
Seeing as nothing has worked for you so far, I have one piece of advice: When you save your .jpg files (the big background images), you might want to save them in "progressive" format if possible.
http://en.wikipedia.org/wiki/JPEG
There is also an interlaced "Progressive JPEG" format, in which data
is compressed in multiple passes of progressively higher detail. This
is ideal for large images that will be displayed while downloading
over a slow connection, allowing a reasonable preview after receiving
only a portion of the data. However, progressive JPEGs are not as
widely supported, and even some software which does support them (such
as some versions of Internet Explorer) only displays the image once it
has been completely downloaded.
Instead of loading the image in a line from top to bottom, it will instead "progressively" become clearer and less pixelated, so you won't see the FOUC as much with the background visible behind it.
Besides this, make sure you provide a background color that won't heavily contrast the image, and try to compress the file size as much as your design can withstand.
I checked your website and found everything to be working as expected. When the browser requests the page with an empty cache, the image will take a few seconds to download. When you navigate to any other page of the website, the browser fetches the image from the cache -- I do not see any flash on FF4, nor I see the browser requesting the stylingbg/weddingsbg image more than once per session.
If you notice that the image is loaded every time you visit the page then probably your browser cache is disabled (or incorrectly configured). The server does not seem to send the Expires header; explicitly specifying an the expires header might help in certain cases.
Also note that some browsers request all resources from the scratch when you hit refresh. Modern browsers (I checked on FF4) will send an If-Modified-Since header, a sensible server will only return a Not Modified response hence no flickering.
Apart from that, I suggest that you add a CSS background color to your page that matches the tone of the background image. This helps in situations when images are disabled or take long time to load. Also consider #Wesley's suggestion about using progressive images. Your current image loads from top to bottom. You can improve the user's experience by converting the image to progressive JPEG.
Use CSS instead.
<style>
body.weddings {
background-image: url('http://www.lookingglassstudio.ca/wp-content/uploads/2011/08/weddingsbg.jpg');
}
body.styling {
background-image: url('http://www.lookingglassstudio.ca/wp-content/uploads/2011/08/stylingbg.jpg');
}
</style>
Then in PHP:
<?php if (is_single(array(11,24,26,28,30,36))) : ?>
<body class="weddings">
<?php else : ?>
<body class="styling">
<?php endif; ?>
I've discovered the source of the issue, and I appreciate previous comments as they have helped immensely!
The problem is Wordpress 3.2, and underlying conflicts with jQuery. These conflicts result in the return of the dreaded FOUC in webkit browsers and sometimes IE.
There is no perfect solution, but all three of the following have greatly helped:
1.) Placing an empty script call right before the javascript call helps 'kickstart' the stylesheet, greatly reduces duration of FOUC white flash.
<script type=”text/javascript”></script>
2.) Downgrading to jQuery 1.4.4. Found here. Evidently the issue is with newer versions of jQuery and WP 3.2 conflicting. A way to do this without affecting admin functions is to add the following to the functions.php file in your theme:
// Downgrade to jQuery 1.4.4 in order to support jQuery Tools
function downgrade_jquery() {
global $wp_scripts;
// We want to use version 1.4.4 of jQuery, but it may break something in the admin so we only load it on the actual site.
if ( !is_admin() ) :
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js', false, '1.4.4');
endif;
}
add_action( 'wp_head', downgrade_jquery() );
3.) Utilizing a similar background color to match your image, as recommended above by Wesley Murch and Salman A. I haven't tried progressive JPEG format yet, but I imagine this would help as well.
The combination seems to almost eliminate the FOUC for Wordpress 3.2, and provides a solution, at least until developers eliminate the problem in future versions.
I'd like to alter the title to more accurately represent the problem I was facing.

Is it possible to prevent saving images from my site?

I have restricted the right click option in my web page, but in IE it shows icons to Save Image, Print, Mail etc . I want to remove all of these. Is this possible?
It seems like everyone else who answered here didn’t read the question.
I have restricted right clicking option in my web page , But IN IE it shows Icons to Save Image, print , mail etc . I want to remove all of these . IS it possible ??
Yes, it is possible to remove these icons. Just put the following in the <head> of your document.
<meta http-equiv="imagetoolbar" content="no" />
As mentioned in the other answers, users will still be able to get the images if they really want to, no matter how hard you try to prevent it. If you don’t want the images to be copied, you shouldn’t use them on a website.
It sounds like you're talking about the Image Toolbar in Internet Explorer. You can disable it with this code:
<html>
<head>
<meta http-equiv="imagetoolbar" content="no" />
</head>
</html>
Or, directly applied to an image:
<img src="test.gif" galleryimg="no" />
No it's not possible. The user can see the image in the browser and thus the browser (and the user) has a copy. You can try and restrict that with nasty (and ill-advised) right-click JS hacks and the like but ultimately if you send something to someone to see or read, what they do with it is beyond your control when you don't control the device they're using.
You can only do so much to prevent some users. To be near 100% foolproof, it's probably impossible. Even if you packaged the images in say, flash, java applet, it doesn't stop users from doing screencapture too.
There are few passive alternatives, e.g. using watermarks, putting up discalimers/warnings.
Here are some related SO posts:
How to disable right-click save on one specific image only
Disable “Save Target As” option in the right click menu
Prevent Save As Functionality
Prevent users from downloading images it's a waste of time because even if they cannot download the image, they always could do an screenshot :-(
if you are using Apache server, you can disable accessing the image through absolute url
the images can be access only with relative url with this htaccess code :
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
in addition, disable the right click context using JavaScript, and add a watermark to protect the copy rights
this will reduce the chance of saving the images
You cannot prevent the downloading of your images. Just by viewing them, the browser caches them.
If the browser can get it, then the user can somehow get it.
You could investigate using an HTML5 canvas or even (gasp) pixelized tables to render client-side.
.show_IMAGE
{
background-position : 0 -100px;
background-image : url('/images/flower.png');
background-repeat : no-repeat;width:50px;height:50px;
}
and add this class to DIV
< div class="show_IMAGE"></ div>
you cannot copy the image alone. if you get image from CSS.
You may try following steps:
Disable right click function on your website.
Disable image dragging on the image you want draggable="false"
Now your website is image theft protected!