toDataURL() enlarges image three times
See original GitHub issueIt seems that toDataURL scales up the png image tree times. The following code should give a 100x100px image file, shouldn’t it? I get a 300x300px file.
If this is by design, I’ll go ahead and compensate for it. But if it’s a bug that will be fixed eventually my compensation will lead to downscaled images when it’s fixed.
return (
<View
onLayout={() =>
this.svg.toDataURL((base64) => {
fs.writeFile(localPath, base64, 'base64');
})}
>
<Svg
width={100}
height={100}
ref={(ref) => {
this.svg = ref;
}}
>
<SvgRect
x={5}
y={5}
width={90}
height={90}
stroke={'red'}
strokeWidth={2}
fill={'yellow'}
/>
</Svg>
</View>
);
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:32
Top Results From Across the Web
toDataURL() enlarges image three times · Issue #855 - GitHub
It seems that toDataURL scales up the png image tree times. The following code should give a 100x100px image file, shouldn't it?
Read more >toDataURL() small screens, small saved image - Stack Overflow
My challenge is that I am using .toDataURL() to get the entire contents of the canvas saved as an image. As I understand,...
Read more >HTMLCanvasElement.toDataURL() - Web APIs | MDN
toDataURL() method returns a data URL containing a representation of the image in the format specified by the type parameter.
Read more >Cool Tricks for Resizing Images in JavaScript - Cloudinary
Resizing images with JS is particularly useful for creating online product galleries, in which users can zoom in or out of images according ......
Read more >HTML5 Canvas Export to High Quality Image Tutorial - Konva
If you need to export a stage as an image or as base64 then you can use the stage.toDataURL() or stage.toImage() methods. By...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Btw, I’ve added support for calling toDataUrl already in the ref function, don’t have to wait for onLayout in javascript anymore.
@msand strikes again =) To me, this is a perfect solution. Thank you very much. I won’t dig into this part of my app in another week or two. Should I use your branch, or will you merge this into master anytime soon?