I have multiple IMGs layered on top of each other (position:absolute;top:0;left:0;), and I need to save all those layers as one solid image. How can I do this? The client's backend is Coldfusion.
Thanks, guys!
I have multiple IMGs layered on top of each other (position:absolute;top:0;left:0;), and I need to save all those layers as one solid image. How can I do this? The client's backend is Coldfusion.
Thanks, guys!
Pretty easy assuming you have multiple transparent PNGs/GIFs (I've done this with coloring states on a US map). Primarily you use imageCopy() and imagePaste() along with image objects.
<!--- below assumes 600x400 images --->
<cfquery name="election">
select state from electionResults where winner='Obama'
</cfquery>
<cfimage source='#expandPath('/imgs/us.png')#" name="usMap">
<cfloop query="election">
<cfimage source="#expandPath('/imgs/#state#-blue.png')#" name="state">
<cfset img = imageCopy(state, 1,1,600,400)>
<cfset imagePaste(usMap,img,1,1)>
</cfloop>
<cfimage action="write" source="#usMap#" destination="#expandPath('/imgs/us-obama.png')#"
overwrite="yes">
<img src="/imgs/us-obama.png">
(written without testing, but looks right)
You will need to use canvas if you are going to do it with JavaScript.
If you are going to do it on the back end, you will need to do it with some image library such as imagecfc