Issue With Image width and Height
See original GitHub issueExpected Behavior
I want to convert a DIV element into the image in react.js. It’s converting exactly that DIV, but it adds some extra width and height in the image, with toPNG, toJpeg functions, with toSvg we get the exact image with same width and height but its base64-size too large, so I want to get the same result in PNG or JPEG with small size. here is the link:
https://codesandbox.io/s/jovial-cohen-ugwum?file=/src/App.js
it should return same result as toSvg in the toPng and toJpeg functions
Current Behavior
I want to convert a DIV element into the image in react.js. It’s converting exactly that DIV, but it adds some extra width and height in the image, with toPNG, toJpeg functions, with toSvg we get the exact image with same width and height but its base64-size too large, so I want to get the same result in PNG or JPEG with small size.
https://codesandbox.io/s/jovial-cohen-ugwum?file=/src/App.js
it should return same result as toSvg in the toPng and toJpeg functions
Possible Solution
it should return same result as toSvg in the toPng and toJpeg functions
Steps To Reproduce
- Remove extra width and height in “toPng” and “toJpeg”
- …
- …
- …
Error Message & Stack Trace
<!-- Provide a log message if relevant -->
Additional Context
Your Environment
window10 Node: v12.16.2 React: v16.13.1
- html-to-image: [e.g. 0.1.0]
- OS: [e.g. macOS Sierra 10.12.3]
- Browser: [e.g. chrome 78.0.3904.108]
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (5 by maintainers)
Top GitHub Comments
The generated image size is based off it’s root node dimensions multiplied by the device pixel ratio. If you want to keep the generated image’s size equal to your node’s, add the following to your config object:
pixelRatio: 1
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.