display, adjust, & combine 2 images with javascript - php

I want to create an application where it can display two images, first image is a face image from user and the second is the nose image that is available to choose to be matched with the face. So when i upload face images, i can choose the matching nose and adjust position, size etc.. then merge them into one image. I want to create with JavaScript and maybe merge them into one using php function, I still confuse where should I start.
Any idea? reference? Thank all

A tutorial for Overlapping Images in php using GD:
Overlapping Images with GD (part 1)
Overlapping Images with GD (part 2)
Overlapping Images with GD (part 3)
other functions to upload images and showing them and handling some user user friendly actions can be done easily with javascript. if there was any question in these parts, I can help.

Related

Using PHP to compare images, not using file date/size

I'm attempting to utilize PHP to compare 2 separate images which may or may not contain the same image. Essentially, they are from an item database application and would have been saved over a year apart. The images are usually resized from roughly 600x600 to 300x300 and in one I checked by eye the image was the same but the file size varied by about 8kb.
Example,
Image created 1/25/2012 is 7,102 bytes
Image created 2/1/2014 is 7,094 bytes
Any suggestions would be greatly appreciated.
Here is a quick and easy way of comparing two images in PHP, based on this blog post.
Tweak the size of $new_img and whether to use grayscaling or not, and find that sweet spot that works on the data you have. When implementing this you should manually check the results a (preferably large) dataset to find out what works best for you.

Inserting an image inside a video at particular position via PHP and a video extension

What I am trying to do is, placing a small static image on inside a video clip at server side, by making use of PHP.
For example, in TV news, you might see the culprit's photo at a corner when the anchor describes about a crime incident.
I've tried doing some research. And found the ffmpeg-php extension for PHP. When going through the docs, I couldn't find any ready made methods or classes that would insert a picture at a particular position if we pass the x and y positions like in GD.
But there is a ffmpeg_frame object available and I think it could be used to fetch frames one by one as an image. And we would do the insertion of our required image inside this using the GD functions. After insertion of the image in all the frames, we would generate the video using these frames. That's my idea. But that extension's docs doesn't reveal anything about creating the video from frames. Only talks about creating animate GIFs !
Would it be a big load for PHP by using the above way of inserting image in each frame and then generating the video from it(if it is possible) ?
Or are there any better ways available to do this insertion process. I mean any other better extensions or video libraries available ?
The aim is to insert an image in a video, which would be at a particular position through out the video.
Thanks in advance.

PHP: Building Smooth Image Transitions on the Fly

I'm trying to figure out via PHP if I can do the following. Imagine I have a two images. The first is an image of a square (50px by 50px). The second image, is that exact same square, only offset by 5px to the left.
I'm wondering if there is a way to dynamically generate all the images in-between to make this a smooth looking image transition (ie in this case generate the other 4 images to make it look like it moved from left to right). This would be a pretty simple situation, however would be applied to more complex images with the exact same premises, essentially using two images to predict the mediums.
Thank you in advance for your help
php would only be a wrapper, think eval() and google it, like http://www.linuxfocus.org/English/September2001/article139.shtml
regards,
/t
I believe the best thing you could hope to do with PHP is to do a 'morph' animation, where you sample the pixels for the first image and the second image, then create a third image consisting of the average color values. Repeating this process you could create as many sub-frames as you would like, but the result would be a blurring / morphing of image A -> image B, and would only be perceived as an animation with the simplest of input images.
More complicated algorithms including edge-detection or hinted-shape tweening could be utilized and implemented, however PHP might not be the best choice for this.
You can dynamically create images with a combination of PHP and ImageMagick.
You can pass in each dimension to ImageMagick, and it will generate an image on the fly for you. Create an image for each pixel you offset, resulting (in this case) in four extra images you can use later for your animation.

PHP generate an image combining several images on different "layers"

I am trying to create a dynamic image that will be created from PHP using GD... What I need to do is be able to specify the layering of one image over another. The images are supposed to overlap slightly and get smaller as you move towards the right of the image... however the only way I can get php to render the images to the left on top of the ones to the right is by reversing the script.
I would like some sort of way to be able to add the images 1 by 1 to the picture from left to right but having the image on the left overlap the one on the right....
Exactly like z-index in PHP, is there a way to do this?
Image manipulation in GD is additive, AFAIK. If you are going to manipulate an image (in your case, create a composite image), then you need to start with a base (maybe a solid background) then add pieces to it.
You can get the effect that you want by performing one of the two procedures:
take the "left to right" stack that you have and reverse it, applying images to the composite from right-to-left.
go "left-to-right" and calculate which part of each image will show around the previous image (to its left). This method is significantly more complicated because the image on the "lower z-index" can show around up to four corners of the image to it's left.

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