Masking and displaying images in php

I would like to create a script where a user can upload an image and see how it looks on a t-shirt. For example:

yummy sweater

I would start with blank shirt images like:

blank

The ad then wants to lay out the uploaded image, keeping the details and shadows of the t-shirt.

Is this possible in PHP? What's the best way to do this?

+3


source to share


2 answers


  • you need - white png image - transparent image in which the inside will be transparent and the outside will be white bg.

  • use the following plugin for overlay and save.



http://www.addyosmani.com/resources/canvasphoto/

0


source


This is how I would do it.

Make the second image you provided semi-transparent in the green area visible below.

Sweatshirt



The rest of the image should not have transparency (white background). What you can do here is draw an image that will be viewed on the shirt. Then you can draw the image mentioned above. This will provide a mask-like effect and you can adjust it there.

While this does the job, I highly recommend that you take a look at the HTML5 canvas for preview as it is more versatile than the PHP GD library and does not require any server resources. You can edit live preview and even save the canvas as an image.

0


source







All Articles