I have been trying to convert an HTML node in my react code into Image and download it afterward. There are several libraries which we can use to perform that job for us like html-to-image, dom-to-image. But the problem is these libraries download the image at its view size, not at its original size. If I have a responsive HTML div that spreads and shrinks with the window size I want to convert that HTML to an image at its original dimensions. How can I do that?
CodePudding user response:
If you want to download the image with the image's original dimension then simply use width
and height
for width and height of the image.
If you want to download the image with the dimension of its container including padding used in the container, then use clientWidth
and clientHeight
property of the image element.
CodePudding user response:
If you want to download the image with the image's original dimension then simply use width and height for width and height of the image. If you want to download the image with the dimension of its container including padding used in the container, then use clientWidth and clientHeight property of the image element. Edited the image for minimum required of pixels.