Remove distortion from image using php - php

I am beginner to PHP image processing. I have an image, I have to remove the distortion from that image and read the date. How can I do that in PHP.
How can I remove destortion from that image and read the date.

There simply isn't any one method fits all type answer. Unless you write some amazingly complicated code that can pick the distortion applied, relate it back on a pixel by pixel basis to what the original was meant to be, you will make buckets of money getting past all the CAPTCHAS used for exactly that purpose - to make sure a human is driving the wheel, not a bit of code.
In theory, you could write a bit of code to apply the opposite of that exact distortion fairly easily, looks like nothing more than a repeated drag has been added to that image - but that will work for that EXACT image, and will likely just make the next image even more distorted.

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.

Read raw color data from PHP's .gd or .gd2 format?

In another question I saw some source, that would export an image into .gd or .gd2 format and then read raw pixel color data from the generated source.
Is this possible? Where can I find more information about these formats, or any other, that generates a raw pixel color data sequence of some sort?
My final goal is quite simple actually. I would like to read the color data of all pixels of an image (say 1000px by 1000px), without having to call imagecolorat a gazillion times :)
It's certainly possible. I've used the technique in a project. What the code does is add alpha channel information from a separate to an image. Something dead simple, but would be insanely slow using imagecolorat() and imagesetpixel().
The data is a read bear to work with. The image is divided into tiles, so getting the pixel at a given set of coordinates is a little tricky.
The information about the format came entirely from looking at the source code. I don't believe there's any other documentation.
The difficulty of directly manipulating pixels in standard PHP was the motivation behind the creation of the QB extension. It lets you do this kind of work at much more reasonable speed. Normalization of pixels into floating point vectors also simplifies calculation a great deal. Might be worth your while to look into.

PDF Verification in PHP

What is the best way in PHP to determine if a PDF is filled out correctly? The source PDF is a faxed form that contains handwritten data. Is an image comparison an option? If the form is filled out on a computer, I know I can use pdftotext to verify that the fields are completed or not. I just don't know how to verify handwritten data.
For hand-written data an image comparison may definitely be an option. See for example the following answer for a basic idea how to start tackling this task:
Imagemagick : “Diff” an Image
However, the job may be much more difficult when faxed images come into play. (We all know how bad a quality you can get from faxes. Also, they frequently are skewed by a small degree. And they may be slightly scaled, compared to the original. Not to forget that their resolution is 204x196dpi, which adds a bit of a distortion. And lastly -- how do you get the faxed form back into PHP? This might involve another step of scanning in the paper, which again will not necessarily add quality to the result.
Still, ImageMagick may be able to handle all this: it can -deskew images, it can reduce or completly remove -noise, and it can -distort, -scale and -repage images and much more...

Changing colors of an image dynamically

I was wondering if it was possible if I had an image like:
I would be able to change certain parts of the images colors. For example if I wanted the bow green and the present red with yellow stripes, would I have to make a new image that had that or is there a way to program something (elegantly) along the lines of that? I'm just asking to see if its possible and if it is, what language would be best to do this?
Keep in mind this would be a feature on a website.
That's not going to be easy the way the image is. You have no way to tell the computer which part is the bow, which part is the stripes, and which part is the box. However, if you pre-colored them, you could do a color replace using GD library or imagemagick pretty easily. You'd do this in PHP. Here are some examples of how you could do it, I'd personally go the imagemagick route.
How can I replace one color with another in a png 24 alpha transparent image with GD
http://www.imagemagick.org/Usage/color_basics/#replace
(this example even has a similar gift box as the usage case, hehe)
Try leaving the parts you want changable transparent. Then, give the div it's in a hover state with the second background color.
You could:
Use an indexed-color image and change the colors in the palette.
Use #MT's suggestion, though it kinda gets out of hand with multiple colors and jagged regions.
Pick control points and fill ("floodfill") the image through them - programmatic version of using the bucket tool.
Use #profitphp's suggestion, which is really better my last one.
Abandon compatibility and use the new canvas element while it still has the "cool" factor :)
i presume this is a web-based painting application; you'll require a human to tell you what the parts are, and where they want the coloring to be.
The issue then becomes how to perform a flood fill at the user's request.
The best i can suggest is perform the flood fill server-side, using an image processing library - handing back the image to the user:
There is no javascript ability to access pixel data of an image.
Edit: Performing flood fill with HTML Canvas

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