G
G
GLaNIK2014-12-01 01:28:14
linux
GLaNIK, 2014-12-01 01:28:14

How to generate an image by overlaying three others?

Greetings!
The thing is, here, it’s like this ...
I, a little understanding enikeyschik, suddenly faced the task of making it so that the user, choosing three options from the proposed images on a web page, would receive a generated image at the output, consisting of them, but superimposed in certain sequence to each other.
All images of the same resolution, same aspect ratio, have an alpha channel.
If I still imagine how to make a selection form, then how to give the user his well-deserved file after that - not at all.
I know that ImageMagic, it seems, can do this.
But survey googling showed that he does not know how to use the alpha channel.
Exactly as in the case if you try to do it through PHP (Not counting the "Solution" with the transfer of all white pixels to alpha).
I would be glad if someone more directly poke his nose in the right direction.
And if he also tells you how to make it so that the user can also set his own color for each of the parts, then he will be happy at all.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
SilverSlice, 2014-12-01
@GLaNIK

Here is an example of how you can do this in php using Imagick:

$image = new Imagick();
$image->readImage('image1.png');

$image2 = new Imagick();
$image2->readImage('image2.png');

$image3 = new Imagick();
$image3->readImage('image3.png');

$image->compositeImage($image2, Imagick::COMPOSITE_OVER, 0, 0);
$image->compositeImage($image3, Imagick::COMPOSITE_OVER, 0, 0);

// сохранить изображение
$image->writeImage('result_image.png');

// или отобразить изображение
header('Content-Type: image/' . $image->getImageFormat());
echo $image;

A
Alexey Nikolaev, 2014-12-01
@Heian

The standard gd2 library can also do this. Watermarks are superimposed by the same principle, with the only difference being that there are 2 pictures, and you have three.
Actually, any algorithm for imposing watermarks is most likely exactly the foundation that will help you.

V
Vladlen Grachev, 2014-12-01
@gwer

ImageMagick.
Image overlays
About alpha channel

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question