Skip to content

How to overlay a PNG image onto another image and dynamically position it using PHP or JavaScript? #120731

Discussion options

You must be logged in to vote

Hey there @tayllana

For those with little time

The merge-images javascript library seems to have been written with litteraly this as its single purpose. It's easy to use. The README.md has examples you can pretty much copy-paste and edit as you like. If you need more image manipulation capabilities during your project, check out these resources.

For those who are interested

I was gonna mention the HTML5 based solution using the canvas. This would use the canvas.drawImage function to draw the image and toDataURL to download the image.

TL;DR: This is pain in the ***. The download part has a catch: CORS causes your browser to distrust your own images used to draw on the canvas. The only way …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by tayllana
Comment options

You must be logged in to vote
1 reply
@CopperEagle
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Programming Help Programming languages, open source, and software development.
3 participants