Programmatically remove watermarked text from image - php

I am developing a web application using php and I need to process thousands of images which are watermarked. How do I remove the watermarked text programmatically from the image and save them?

You can't, this is impossible. That's the point of watermarks.

Visual recognition - as in the case of differentiating a watermark from the rest of an image - is in the domain of artificial intelligence, and it requires A LOT of neural network training.
If you can write a perfect algorithm for this one, you can break any CAPTCHA too. So good luck if you manage to do it! That said, you might be way over your head on this one.

Images with watermarks got them for a reason (Often due to copyright).
Removing them can lead their author to sue you.
That said, you can't do it automatically or/and programaticaly. If you really need to remove them, do it manually and buy Photoshop­©

If anyone can remove the watermark of the image by just putting a simple code, then what is the use of firstly putting them on the images? It is of no use if anyone can easily remove it.
It can be removed by image editing by tools like Photoshop etc. But that will make you violate the copyrights law of the image owner. If you really need that image, request the owner via email or something.

Don't try to remove. Try to guess the link without watermark
Ex:
watermarked
http://domain.com/36436/34fdhfh_wtm.jpg
no watermark
http://domain.com/36436/34fdhfh_nwm.jpg
:) of course it is not that simple (depends on the website owner) but somehow there might be a rule though

Related

How to convert wordpress post into image and make it downloadable?

I had created one wordpress site. I want to make all post downloadable by converting it to image.
I tried using canvas but didn't succeed.
Can any one suggest me better working way on wordpress which lets me convert my post to image and make it downloadable?
I want to make post covered with specific div so that i can define size of content to be downloaded.
Like this HTML2CANVAS but I am unable to do.
PS-I have very small size of content in every post
I think your options are
Use some third-party service, such as http://web-capture.net/ or https://www.url2png.com . Most of them, especially the ones with API that you can call on-demand, will cost you, but there are free alternatives.
If you have access to linux console and some basic knowledge about it, the best approach is to run a real browser (if you're using a headless server, use Xvfb) with your post URL and make a screenshot with ImageMagick. You can crop the image to remove browser header etc. A working-grade explanation here http://www.leonardteo.com/2011/07/taking-server-side-screenshots-of-websites/ .
In both cases PHP will be just the trigger, whether it will call third-party API or your local shell script.
I'd also suggest to avoid JPEG format as it doesn't really play well with text. Use PNG instead.
You may try rendering the text with imagettftext() as #Progrock suggested, but this will be a huge pain, because you obviously have text with more than one line. First you need to determine the width of your image, then use imagettfbbox() to roughly estimate how many characters you can fit into one line, split your text into chunks of that size and write then one by one, adding the Y coordinate. Bonus points if you need paragraphs here... Make sure you're using monotype font, because it won't ever work properly with variable-width letters. look through comments here http://php.net/manual/en/function.imagettftext.php.
My advice - stick with the browser :) You can resize the browser window and crop the extra part.

How we can protect images in our web application?

I am working on a web application using PHP and application consist lots of images.We are also using same image when creating a PDF in our application and users can also download/save from PDF. I am worried that these can easily be taken by unscrupulous individuals. Is there any way to protect these images ? Any suggestion would be appreciable.
Thanks in advance :)
It is absolutely impossible to protect the images that user see.
If you aren't convinced, a simple evidence: you can simply take a screenshot. And voila! Here are your images. Even if you came up with the wittiest solution ever invented.
The only possible ways of securing your images are:
very ugly - adding a watermark
reducing the image size - assuming it's only worthy in hi-quality
Also, keep in mind that even if you came up with cool technology, eventually cooler guy would come down and crack your security. So my advice is, don't try wasting your time on this idea. Instead, try planning better access-to-these-images work model and/or limit the number of valuable images shown to just few.
If the user has access to view the image, they can screen print it. You cannot protect it unless it is behind a login area for instance. You could add a watermark to help deter this but they can still take the image and crop the watermark off.

how can i restrict a user to see only the slideshow and can't download it

i am developing a cake-php application, under this i want to show powerpoint slideshow for the end user but the condition is that the user can only be able to see the show, not be able to download the slideshow.
Can any one plz suggest the best way to do it.
If the slideshow is based on images you can split each image into 9,16 or more squares and display the tiled image. That way if the user decides to 'Save-as' the image he will get only 1/9, or 1/16-th of the real image. If the slideshow is quite big it will be a pain to put together all the pieces and will discourage the users to try and save the slide.
You can see such implementation here - http://whatismycar.com/info/16540/ - the 4 images below the header are in fancybox and if you try to 'Save-as' one of them you will save only a small tile of the original image.
Hope this helps.
It is impossible prevent downloading images from internet, but you can make it hard for users with this. Also you can hide source html image path with php check it here
While I am no expert on this subject, something worth noting is what Youtube seems to be doing.
Ever notice how the whole video never loads if you pause it?
Upon monitoring the network tab during a video you will see that they are actually making hundreds or even thousands of requests for video segments from their server and most likely using JS to clear the cache of parts you've watched.
^^ this is why going back to an earlier point in the video causes it to stall for a bit while it re-downloads the segment which you wish to see.
At the end of the day, PrtScn will trump all of your efforts because the web browser does not have the privilege to control the keyboard outside of it's own environment.

Resize an image before user downloads it?

So this will no doubt come as a stupid question from an ignorant person, but I was wondering if there is any easy way out there of resizing an image BEFORE a user downloads it?
I am pulling in images from a 3rd party database, which I have no control over. I'm also not allowed to cache anything from it under their T&C.
They give a few different sizes for each image. But I am ending up resizing half of them on my pages with CSS.
So I was wondering if maybe using php or javascript or something! (I really have no clue do I), I could resize these images before my users waste time downloading much bigger versions.
The only reason I ask really, is that I know the Manchester United website kind of does it (with the aid of a piece of Adobe stuff I think), so I thought that maybe there might be something out there that anyone could use?
http://www.manutd.com/en/News-And-Features/Football-News/2011/May/Sir-Alex-Blackburn-reaction.aspx
http://www.manutd.com/~/media/64B766EE4A37488AA65DC7B08E5ABC1B.ashx?h=179&la=ar-SA&w=480&rgn=0,78,1200,524
-> 18kb compared to 160kb -> http://www.manutd.com/~/media/64B766EE4A37488AA65DC7B08E5ABC1B.ashx
(obviously I don't want the cropping technique)
If the images are coming from a server you don't control, the short answer is NO. You can't resize an image until you've downloaded it. Without caching a resized version, you are at the mercy of the 3rd party server. Unless you use a server side proxy program, yet this is probably more trouble than it is worth.
Yet as I've pointed out in the comments, http://www.manutd.com will resize their images for you. In the link h=height, w=width and rgn=region (left,top,right,bottom)
http://www.manutd.com/~/media/64B766EE4A37488AA65DC7B08E5ABC1B.ashx?h=80&la=ar-SA&w=120&rgn=0,0,1200,800
You only need the h and the w. If your h and w don't match the aspect of the image it will crop rather than skew. look at both of these. The image is 1200x800 aspect ratio 3x2
w=240, h=160 3x2 (whole image)
http://www.manutd.com/~/media/64B766EE4A37488AA65DC7B08E5ABC1B.ashx?w=240&h=160
w=160, h=160 1x1 (cropped)
http://www.manutd.com/~/media/64B766EE4A37488AA65DC7B08E5ABC1B.ashx?w=160&h=160
After I've played with it more, you can get by with just the width(w), and I'm assuming this also applies to just the height. (EDIT: yes it does)
Whole image, 480px wide...
http://www.manutd.com/~/media/64B766EE4A37488AA65DC7B08E5ABC1B.ashx?w=480
MORE EDITING: Understand, any time you see a '?' in a url, you are requesting a page from a program, and the stuff after the '?' are parameters for the program, and '&' seperates the parameters. The server at manutd.com is using a program to resize their images, just like a proxy program would resize images for you. If you did resort to a proxy program, if it was a decent one, it would take a link like http://YourServer.host/proxyProgram.php?img=imageHost.org/imageName.jpg&w=240&h=160 given a link such as that there are all sorts of server side solutions to resize the image.
Yet without a cache there is the possibility that you will resize the same image many times, and just the thought of that turns me off.
I'm gonna quit editing now!
Have fun!
Skip
Try using ImageMagick for PHP. It allows you to resize and modify images server-side. There are some examples here
Just off the top of my head, here's a pretty ugly way to get it done:
Create a PHP page that takes all of your requests. So instead of doing this...
<img src="http://other.domain/img.jpg" />
Do this:
<img src="http://your.domain/images.php?name=img.jpg" />
Then have your PHP page grab the image from the 3rd party site, and recreate it at whatever size you need:
$newe = imagecreatetruecolor($width, $height);
$old = imagecreatefromjpeg($fullpath);
$oldSizes = getimagesize($fullpath);
imagecopyresampled($newe, $old, 0, 0, 0, 0, $width, $height, imagesx($old), imagesy($old));
header('Content-type: image/jpeg');
echo $newe;
Some stuff that might trip this up:
If the T&C doesn't allow caching of images, they might not allow you to access their images with server-side code.
You'll have to adjust some of the code if you're doing other image types (gif, png)
This has to be done on the server. The technique used depends on what you're using on your server. If it's .NET, there is built-in functionality to handle resizing.
# Taze well server side, but he gets the images from another server and it seems you have not read it what he is doing and what he is allowed to do.
theoretically you could cache it (what you are not allowed to) on your own server, resize it with gdlib or imagemagick and give it to the user and then delete the copy from the server
but thats against the rules of the 3rd party

Recognize image with PHP

I run a site with lots of small images (www.iconfinder.com) and would like to develop a feature that can compare and recognize images. A user should be able to upload an image (icon) and then the site will respond with information about the image if it's in the database.
What is the approach to finding similar (or the same image). I know I can compare md5 of the two images, but I also want be able to find matches if the are scaled.
This is a good start if you are interested in looking at doing it in PHP:
http://www.intelliot.com/blog/2008/03/sorted-directory-listing-image-resizing-comparison-and-similarity-in-php/
There probably aren't a lot of languages LESS suited to this task than PHP. You should really look for an image comparison library with a C compatible API and figure out how to glue that into your PHP application.
Identical images can be checked with an md5sum, but detecting if somebody uploads a scaled image, which displays the same thing as the other is very hard. This requires digital image processing.
An approach is to scale down all images to a certain width (say 100px). Then check a few coordinates for the color. If another image matches a big part (say 80%), it might be the same image.
But if the image is lighter... this won't work.

Categories