I'm displaying pieces of an image in a large grid created from divs. I'm using the background-image and background-position to display portions of the image. The problem I'm running in to is that a user can simply open up firebug and see the entire image (which defeats the purpose of the game).
I've attempted to mask the path using a php script as the URL but if the user navigates to the php file, they can still see the image. It would appear that anything I do with the CSS is entirely client side so denying everything outside the localhost in my .htaccess won't work.
Any suggestions?
The over arching goal is to have an automated way to split and display pieces of the image into a grid.
If you deliver the whole image to the browser, the browser holds the image and has every right to show it to a user. I don't think you can prevent the browser from showing it. I'm afraid you will have to deliver the image in pieces, or perhaps write your whole game using <canvas> and play around with images as pixel data. :)
Related
I have an iframe that shows a picture generated by a software on the server. The image size is sent in pixels to the software by a parameter in the command line.
The iframe size is set relatively, using <iframe width="100%" >, no problem with that. But in small screens, if the iframe gets smaller than the picture it causes a bad effect, with undesired scroll bars to show the hidden parts of the image.
Is there a way to know the size of the iframe in the browser, or the screen itself, so I can send the correct size to generate a picture that will fill properly in the iframe?
(I guess this is used by responsive themes)
EDITION: I'm reasking this in another way here How to make it sure that an iframe content fits it?
The best approach would depend on the method in which the image is loaded into the iframe. The size of the iframe would have to be determined on the client end, so it would be out of reach for PHP.
I'd personally load the image with PHP on the server end and avoid iframes. If you are loading the image after the page is loaded, you might want to reset the iframe's size using javascript(or jQuery).
If you could provide more detail about how the image is loaded into the iframe, it would help figure out what exactly you're looking for.
I have a script that displays the images via php. www.maindomain.com/image.php?img=test.jpg serve images, and i have other sites, where these images are displayed like this
<img src="www.maindomain.com/image.php?img=test1.jpg">
But this script, for show image is on my www.firstsite.com and www.secondsite.com. Is posibble to log which site is showing image? (put it to database for example).
I know, i can use $_SERVER['HTTP_REFERER'] but it's not 100%. Any other ideas?
The only 100% failsafe way to do it is to share the same image with different URLs. F.i. www.maindomain.com/image.php?test1.jpg&ref=first and www.maindomain.com/image.php?test1.jpg&ref=second. As actually this images are not requested by first or second servers but by visitor's browsers. Having different GET params in URL makes it easy to log data you need.
I Googled a lot but no sufficient ans was found.
I need to place an image (900 X 5200 px) in one of my pages. As the image is sensitive, I need to prevent users from copying the image. I have an idea that can do this:
I will divide the image into pieces. Then the image grid will be loaded into some divs. So user won't be able to save the image. Or he/she will save only 1 square cm part of the whole image.
But this plan will not work if some small parts of the grid fails to load. So, I want to do another thing. I want to load the full image then cut the image into parts. Then show the parts altogether in divs.
This requires javascript. But I am confused how to start and need your help.
Now you know the matter, if you have better idea please share.
Thanks in advance.
The trick is simple. Create a div with the background being the image you want to display. Layer a div with a transparent image over it. When user goes to save the image, they get a blank. Program your server to not return "direct" requests for the image (so some clever chap can't just look at the css and retrieve the URL to the image).
Granted the image will still be in their cache but so would the sliced image so it won't make it impossible just more difficult for a determined person to retrieve the picture.
TL;DR Don't over engineer a solution, print screen will get around anything you do.
You are not going to be able to prevent people from copying this image. Plain and simple. Regardless of your best efforts, a simple PRT SCRN and paste into Paint will be enough.
Your best bet will be to not over engineer this and simply place a watermark and copyright notice on the page. Other options can include placing a transparent <div> over the top of the image so it cannot be right-click'ed and saved, but it still will not prevent the image from being stored in the user's cache. Or stop them from using developer tools or Firebug to find the source image.
You can do this with:
http://www.pixastic.com/lib/docs/actions/crop/
Yet you need to develop your logic around that library.
I have made example, you can see it on this link:
http://simplestudio.rs/yard/crop_img/
Basically you can get URL to your image via php and using my code or code similar to it crop your image into pieces and display them on canvas.
This way image is not accessible via browser or inspect element or what so ever. User can save the pieces individually but you can configure my code for piece to be 5px, I set it to 20x20px.
* test saving image piece by doing right click anywhere on image and do a "Save image as.." option.
Also you need to think of way how to hide src to image provided by php, if you need help on that I can help you.
Image this scenario:
There is a picture locally in my server, where a sketch is displayed, and there is a "blank hole" area on it.
Then, a user can upload another picture to my server.
What i'm trying to achieve is this:
After image upload is finished, the first image (the one with the "hole") is displayed, and behind it is displayed the user's photo, so that you can see it through the "blank hole" area of the first photo.
Then the user can move his picture (drag & drop style) so he can choose which area of it is visible through the "blank hole".
Then i would like to save the result - by merging the 2 photos or keeping the position of the user's picture in a db so i can display it again later.
(Something like this more or less)
What kind of technollogy should i look for? I'd guess javascript(for the drag & drop) or html5 or php(for merging the photo)?
Are there any libraries that i can use?
I hope my explanation isn't too messy, i didn't even know how to google for it.
I don't know if there are better solutions (and I suspect there are), but I suspect all of this can be done with not too much trouble. Here's a rundown of one way to approach the problem:
Use a JavaScript-powered "upload widget" such as uploadify to enable your user to upload "his" image to the server. The server will do some processing on the image (e.g. resize and crop to suitable dimensions) and save it using e.g. PHP's gd library. It will return a URL to the "prepared" image back to the browser -- all of this through AJAX.
The browser then has a URL to the user's image, so using more Javascript you can dynamically add an element that displays it inside the page and allow the user to move it around with e.g. jQuery draggable. Compositing the draggable image behind your static content (the image with the "hole") is a detail you will have to take care of using a combination of HTML, CSS and again Javascript.
When the user is done, use an AJAX call (e.g. again jQuery) to inform the server of the image's positioning (this will be available through the facilities of the Javascipt framework you have selected). The server can then "compose" the two images together (gd or something equivalent once more) and return to the browser a URL through which the final product can be accessed.
Of course there are lots of details to take care of here, but knowing exactly what the plan is should help you get started.
Have a look at the PHP GD extension. If it's installed, it's pretty easy to have an image (with a transparent center) to be merged on top of a second image that a user would upload.
Have a look at http://php.net/manual/en/function.imagecopymerge.php
Ok to get you started, yes use a JavaScript drag and drop module for the placing of the image. You can record the x /y cordinates relative to the container. Do the image merging with a PHP image library / Class. Something like this : http://www.phpclasses.org/package/3930-PHP-Generate-an-image-from-the-combination-of-2-images.html
This question is a bit open at the moment as I'm not sure the idea is even possible.
So far I've loaded an image from a url, and then used jQuery UI draggable feature to allow the user to drag html text (which has been replaced using cufon font replacement) over the top of the image.
The major step (which is what my question relates to) is being able to take the image and text layered over the top of the image, and save the result, either to the server, or potentially offer the option to save the altered image to the user's HD, or what would also be useful is to upload to facebook using the facebook API, but this is something I know is possible.
It all hangs on whether it's even possible to achieve the first step, which is to save the image and layered text as a combined image?
I wonder if there is a PHP/jQuery solution that would allow me to do this?
My suggestion would be to have an internal URL that outputs the final image using jQuery and PHP, then take a screenshot using webkit2png of that page. You should know the dimensions etc., so you'll be able to crop down the resulting screenshot to just the region you're looking for.