I'm new to imagemagic aka imagick on php and im trying to follow this thread using php code. I have tried to apply this logo onto a tshirt but couldn't do so by following the threas becuase i cannot find most of the methods in php like using displacement map to start with. What i have tried is the following code:
$image = new Imagick($_SERVER['DOCUMENT_ROOT'] . '/images/VYLZsoD.jpg');
$logo = new Imagick($_SERVER['DOCUMENT_ROOT'] . '/images/logo.png');
$logo->resizeImage(200, 200, imagick::FILTER_LANCZOS, 1, TRUE);
header("Content-Type: image/jpg");
$image->compositeimage($logo, Imagick::COMPOSITE_DEFAULT, 400, 260);
$image->flattenImages();
echo $image;
I would want to use the steps shown in the thread to create a mask and so on in order to apply the logo onto the tshirt using php code (not via command). I have even used "COMPOSITE_OVERLAY" to make the logo look like its part of the tshirt but it seems like the original color of the logo reduces because of the transparency, check here for my final tshirt http://i62.tinypic.com/2ahuw6h.png.
- Please tell me how i can archive a better result using imagick in php (without the color of the logo is being reduced)
- Can i mark a territory on the tshirt so that when i drag the logo around, it wouldn't show outside the tshirt border?
Source tshirt http://i58.tinypic.com/154j52b.jpg Source logo http://i59.tinypic.com/e02051.png
I hope, this effects will help you.
(this page has much effects, so you can search with F3 (tshirt) )
Here;s the final code for my 2nd question:
Output Output http://i59.tinypic.com/23h7nzs.png
The second part of your question, how to get the creases to show through 'nicely' is possibly a bad idea. There are two problems with attempting it:
i) The distortions in the tshirt are physical displacements. Although you can get the crease lighting to show through, it's really hard to get the logo to look realistic without also having the same physical displacement.
ii) Colors really don't behave consistently. Just having the logo be lighter/darker by the same amount as the tshirt crease may produce unrealistic effects. e.g. dark tshirt + crease = 50% brighter background. Bright blue logo + 50% brighter crease effect = unrealistic looking blue highlight.
I would recommend having a flat tshirt as the background as unrealistic effects tend to distract people. But you could do it like this:
Produces an image like:
The output image you posted doesn't look like the output image I see when running your code. Obviously adjusting the position a little, the output image I see doesn't have the color reduced.
If you don't see see the same thing, it may be a bug in your version of ImageMagick. You could try using the composite method COMPOSITE_ATOP, which should produce the same result, via a different blend method.
For your second question, how to limit the logo overlay to the edge of the Tshirt, you can do it by creating a mask out of the tshirt, painting the logo onto that mask with COMPOSITE_SRCIN and then painting the result of that onto the tshirt:
Which produces something like:
Whether that's a good idea or not is another matter.