PHP image manipulation wrapping image on of another image - php

I'm working on a PHP project where the user can upload an image and preview that image on a product (Ex. mug, pillow). I have done almost all that is required to implement this except wrapping the uploaded image around the product image. I have done extensive search on that, but could not find any help. Could anyone show me the way please ?
At the moment I am using the GD library.
Best example for what I need is : http://www.zazzle.com/polyester_throw_pillow_16_x_16-189271445174968378
I am not sure how they are doing that.
EDIT :
My area of interest is how they are blending the image according the product shape

I think it's answered here: Merge two PNG images with PHP GD library
Just make sure that the image uploaded by the client is smaller than your product image

Related

Preview page Image orientation

I picked up some work updating images on a website that someone else had created managed previously.
I determined how it was laid out enough to get what needed to be done done.
However, two images I added are showing in landscape orientation on the preview page but when the image is clicked on it shows properly in the portrait orientation.
www.artbyheenan.com/art.php
Its the first two images, if anyone can take a look and give me some input I'd appreciate it.
Initially I thought it may have been the image size as it was rather large and I resized it to 200kb but still the same.
It has to do with the images meta/exif data and a known issue in the browsers.
- https://github.com/GoogleChromeLabs/squoosh/issues/299
- Chrome Image EXIF Orienation Issue
The best solution right now is to re-save the image in photoshop or something similar.
The problem is that your images have EXIF data that has rotation set to 90ยบ CCW.
If you delete the EXIF data, they will display properly.
You can do that here: Remove EXIF data online

Image upload crop resize save to folder

I want from user to upload an image of any size for (jpg,png,gif) format. After uploading the image I want him to crop the image (client side) using jquery and save that cropped image (php) to application folder.
Please tell me the feasible solution to make this functionality working fine.
ImageMagick is used for croping images:
http://www.sitepoint.com/crop-and-resize-images-with-imagemagick/
For using ajax:
http://www.sanwebe.com/2012/05/ajax-image-upload-and-resize-with-jquery-and-php
Given that you already have the PHP code to crop, use one of this plugins to allow the user define how she wants to crop the image and provide the data you need:
Guillotine: Very lightweight plugin that allows to crop, zoom and rotate images with touch support and it's responsive (demo).
Jcrop: Allows free selection cropping (demo).
It is simple image crop using jquery and php using cropbox.js
Please watch the following video
Simple image crop

Add watermark to images

I've searched for ages for a solution, but I can't really find the solution to fit my needs.
So here's the story. Im creating a website and I really want to add watermarks to the downloaded images.
Yesterday I was browsing in a website called 9gag. If you haven't heard this website before, its a comic based website, and I found out that when you download an image, or access an image from anywhere else except their website, there's a 'watermark/banner' at the bottom of the image.
For example take this image:
link , notice no banner at the bottom of the image.
If you right-click, 'Copy image URL' , you get this link: image . See the banner now?
Im very confused on how they do it, and it would be great if we could use this on our websites.
Anyone with any ideas? Is it using any type of CGI?
P.S: I Wasn't sure what tags to add, So if anyone knows a better tag combination, please do edit it.
This effect is just a css trick. The image itself actually contains the watermark at the bottom, but the image tag is wrapped in a block that hides (overflow:hidden) the bottom 42 pixels of the image when it's being displayed in the page.
There are other things you can do that are more sophisticated (for instance, have the image served via a php script and comparing the http referer
header("content-type: image/jpeg");
if (!isset($_SERVER['HTTP_REFERER'])){die("alert('Restricted Access!');");};
$_u=parse_url($_SERVER['HTTP_REFERER']);
$_u=preg_replace("/(www.)/i","",strtolower($_u['host']));
$_i=$_SERVER['HTTP_HOST'];
$_i=preg_replace("/(www.)/i","",strtolower($_i));
if ($_u != $_i){
//handle this with gd or redirect
}
) but this will only work if someone tries to load the image from a different website or if they go to the image url... generally save-as will save the image from the browser's cache, so the css trick might be the best option you have (or a combination of these options). Fundamentally keep in mind that anything you show on the web can be captured (the code above isn't foolproof, and you can always prtsc).
GD library of php will help you doing that.
You'll need to create a new image using imagecreate function but adding some more "space" to the original size. Example: if I have an image of 200x200 (which you can retrieve using gd functions too) you'll need to create a 200x220px image using that function
Fill the new image with that gray color using imagefilledrectangle function
Copy the original image into the new one using imagecopy
Set the header's content type to image/type png gif etc..
Output to the image using imagepng or any other function that has the format you want.
I've had success with JQuery Watermark:
Jquery Watermark

Create Dynamic Images using Base Image

I am creating a Google Maps Social Application.. I have a basic marker that has a blank square in between it where I need to put the user uploaded picture.
I already have the user uploaded pictures. Now How do I create these dynamic markers using PHP.. The accepted pictures are jpeg and png.
I have heard of the PHP GD Library and would like to know how I can accomplish the task..
You can create the base image with this :
imagecreatefromjpeg() & imagecreatefrompng()
you can determine which one to use by getting the image information with getimagesize().
After you have your base image you can do the same with the user image and copy it to the base image with imagecopyresized()
You can see a couple of useful examples on the user comments at: php.net/imagecopyresized
I hope this answers your question, if not just ask me and I'll find the time to give you a more complete answer.

Image upload and jCrop and codeigniter

I am trying to build a system that allows a user to select an image from their own computer, and crop it using the jCrop tool from jQuery. My question is can I show the image the user has selected from their system without uploading it to a system, I dont really want to do two uploads, unless I can do the first upload silently? Any help would be great.
Thank you.
You don't have to upload twice. Just upload the image at first time
Use jCrop and send image Thumbnail's coordinates(x,y), width and height.
Resize Image according to them
AFAIK, not using JavaScript and HTML (4) at the moment.
Flash can do image processing before upload - SWFUpload for example can resize images before uploading (doesn't support cropping though), but I don't know an Open Source implementation of a Cropping tool in Flash.
It will probably also be possible using HTML 5.
However, I don't see how you would need two uploads to do this? Isn't it 1. Upload 2. Show with Cropper 3. send Crop info to PHP script that processes the uploaded file?

Categories