I have a div element which contains two or three images. One of image are transform with some scale and rotation.I Just want to convert whole div into single image. I used html2canvas and i am a huge fan of that , but my problem is that the image with transform property is not same across all browser it works fine in chrome but not in Mozilla and IE.I am also using latest version of html2canvas in which transform is supported.Can you suggest me another way to convert div into image using only javascript not jquery.
1 Answer
If you are only needing this for images and need to track transforms, then I would suggest using only canvas for this.
Insert a canvas element inside that div instead of the images, and paint onto it the images you need with the respective transform (translate, rotate etc.). From there it's simply to call toDataURL() to save everything as a single image.
Note that CORS restrictions applies (images must be loaded from same server as page, or given permission to be used outside CORS by the hosting server - one exception are images uploaded through a input field).
There exists many examples on SO for how to setup a canvas and draw images with rotation/transforms.