Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output image being cropped #121

Open
ericman314 opened this issue Jul 8, 2020 · 0 comments
Open

Output image being cropped #121

ericman314 opened this issue Jul 8, 2020 · 0 comments

Comments

@ericman314
Copy link

I'm having trouble generating a png image correctly. The output png image is the correct size, but the figure is being cropped to 400x300 no matter what output size I request.

Here is my code. In this example, imageWidth is 479.

let pngBuffer = await svg2png(Buffer.from(svgString), { width: imageWidth })
await fs.writeFile(filename, pngBuffer)            

The first line of svgString is:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" preserveAspectRatio="xMinYMin meet" viewBox="-80.9714977388259 -166.4741201283966 287.97746576236545 251.25923173892323" width="100%" height="100%">

The output image size is correct at 479x418, but only pixels in a 400x300 rectangle are drawn.
image

The output image should look like this:
image

What am I doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant