exupero / saveSvgAsPng

Save SVGs as PNGs from the browser.
MIT License
1.09k stars 362 forks source link

Size of downloaded image varying according to the zoom level of browser #231

Open hasimpk opened 4 years ago

Abercus commented 4 years ago

For a quick hack fix the devicePixelRatio to the actual size. This is the variable that changes when you change zoom in a browser. Change the following line:

https://github.com/exupero/saveSvgAsPng/blob/gh-pages/src/saveSvgAsPng.js#L315

const pixelRatio = window.devicePixelRatio || 1;

to not use the window.devicePixelRatio e.g.

const pixelRatio = 1;