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

Improve error messaging when attempting to render SVG > 32767x32767 #3167

Closed
nishantjiit opened this issue Mar 30, 2022 · 2 comments
Closed

Comments

@nishantjiit
Copy link

nishantjiit commented Mar 30, 2022

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • [X ] Running npm install sharp completes without error.
  • [X ] Running node -e "require('sharp')" completes without error.

If you cannot confirm both of these, please open an installation issue instead.

Are you using the latest version of sharp?

  • [X ] I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

System:
OS: Windows 10 10.0.19042
CPU: (4) x64 Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
Memory: 2.02 GB / 7.66 GB
Binaries:
Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
npm: 8.1.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
sharp: ^0.30.3 => 0.30.3

What are the steps to reproduce?

I am using following code to convert SVG to TIFF.

const sharp = require('sharp');

sharp("error-svg.svg", {limitInputPixels: false})
    .flatten({ background: { r: 255, g: 255, b: 255, alpha: 255 } })
    .toColourspace('b-w')
    .threshold(255)
    .withMetadata({ density: 300 }) // This is only to update the properties. Does not have any impact in SVG rendering.
    .tiff({bitdepth:1,compression:'ccittfax4', quality:100, resolutionUnit:'inch'})
    .toFile("output.tiff")
    .then(function(info) {
        console.log(info)
    })
    .catch(function(err) {
        console.log(err)
    });

Without limitInputPixels: false it says:

[Error: Input image exceeds pixel limit]

With limitInputPixels: false it says:

(process:8848): librsvg-WARNING **: 11:06:57.559: cannot render on a cairo_t with a failure status (status=InvalidSize)
[Error: svgload: SVG rendering failed
glib: rendering error: InvalidSize

]

For smaller sizes it is working fine.

What is the expected behaviour?

It should convert the large SVG files to TIFF without any error. For error-svg.svg: width="114958" & height="6968".

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

listed above

Please provide sample image(s) that help explain this problem

error-svg.svg

@lovell
Copy link
Owner

lovell commented Mar 30, 2022

librsvg supports rendering SVG images at up to 32767x32767 pixels - there's a related discussion at libvips/libvips#2296

We can probably improve the error messaging, I'll tag this as an enhancement.

@lovell lovell added enhancement and removed triage labels Mar 30, 2022
@lovell lovell changed the title Error while converting large SVG files to TIFF Improve error messaging when attempting to render SVG > 32767x32767 Mar 30, 2022
@lovell lovell added this to the v0.30.4 milestone Apr 4, 2022
@lovell
Copy link
Owner

lovell commented Apr 18, 2022

v0.30.4 now available with improved error messaging.

@lovell lovell closed this as completed Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants