You've received a more technical answer already so I'm going to focus on the creative aspect of things. You've also mentioned familiarity with the associated php
libraries and even previous attempts to create similar compositions that seemed to lack luster in the end.
In my opinion, this endeavor is far more reliant on artistry, creativity and, most importantly, prepared assets. By manually preparing these images you will have more finesse over the final result as well as leave only the simple compositing to php
. Not the entire editing process.
Frankly, such detailed results are not achievable via an API. This project will require hours of manual labor and editing. Paying attention to lighting, transparency and colors.
The most impressive effects are the ones where objects in the photo overlap the user-added image. Ie:

While this example is rather simple, the same logic applies to more complex compositions.
- You need to start with a high resolution image. Especially if you will be offering physical prints to your users.
- The high resolution is also quite necessary as you will have to edit and prep these in a program like Photoshop beforehand.
- For best results these will require complex, compound masks in Photoshop. Think sharp and smooth alpha transitions. Don't just cut everything with hard lines.
When considering the example above, you would be able to get away with only one layer in photoshop. Simply cut a hole where photos will be placed and export as png
.
For other examples I would recommend separate background and foreground layers, with the user-added image sandwiched in between.

This is another great example where resolution is of utmost importance. The leaves are way too small to be effectively masked out at a tiny resolution. Some of the leaves may also be blurred and out of focus; again, don't cut them with hard lines. For best results, use a soft brush when masking them in Photoshop.
And last but not least, here's a very simple hands-on example.

Note how the background image has a smooth mask while the leaf has a hard one. Frankly, parts of the leaf are out of focus and can be further refined. The investment of time you make here will make the world of difference in how convincing your final results are.
Save out each layer as a png
and composite within php
. I would recommend making sure each png
has the same dimension. Don't try to position a tiny png
over a larger one. Give them the same dimensions to make alignment a breeze.