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

Create a PNG, the height cannot > 200000 #2539

Closed
mclxly opened this issue Jan 19, 2021 · 8 comments
Closed

Create a PNG, the height cannot > 200000 #2539

mclxly opened this issue Jan 19, 2021 · 8 comments
Labels

Comments

@mclxly
Copy link

mclxly commented Jan 19, 2021

Are you using the latest version? Is the version currently in use as reported by npm ls sharp the same as the latest version as reported by npm view sharp dist-tags.latest?
0.26.3

What are the steps to reproduce?

const LIMIT_INPUT_PIXELS = 177610406400

sharp({
            limitInputPixels: LIMIT_INPUT_PIXELS,
            create: {
              width: 2250,
              height: 201000, // cannot > 200000
              channels: 3,
              background: { r: 255, g: 255, b: 255 }
            }
          })
            .toFile(`./tmp.png`, function(err) {
    console.log(err)
  })

No error report but image is corrupted/unused.

What is the expected behaviour?
Creat image success

Are you able to provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem?

Are you able to provide a sample image that helps explain the problem?

What is the output of running npx envinfo --binaries --system?

@mclxly mclxly added the triage label Jan 19, 2021
@lovell
Copy link
Owner

lovell commented Jan 19, 2021

Hi, this example works for me locally on Linux, albeit rather slowly. When dealing with such large PNG files you might want to lower the compressionLevel setting.

https://sharp.pixelplumbing.com/api-output#png

My best guess would be that you're running out of memory. The example image is 2250 x 201000 x 3 bytes, around 1.4GB, when held uncompressed in RAM.

@lovell lovell added question and removed triage labels Jan 19, 2021
@mclxly
Copy link
Author

mclxly commented Jan 19, 2021

@lovell My system is MacOS Big Sur 11.1 with 16GB RAM. I guess other limitation in unknown place.
I'm building a tool for webpage screenshot, some pages are really height.

@lovell
Copy link
Owner

lovell commented Mar 8, 2021

@mclxly Were you able to make any progress with this? The prebuilt binaries provided in the next release of sharp should offer faster PNG output - see #2604

@mclxly
Copy link
Author

mclxly commented Mar 9, 2021

@lovell Thank you for your great job. Currently I make all images lower than a fixed number. I will upgrade it later.

@lovell
Copy link
Owner

lovell commented Apr 5, 2021

v0.28.1 is now available with improved PNG compression performance. Are you able to test to see if it has helped?

@mclxly
Copy link
Author

mclxly commented Apr 7, 2021

@lovell no lucky, same error.

await sharp({
                  limitInputPixels: LIMIT_INPUT_PIXELS,
                  create: {
                    width: 1000,
                    height: 200000,
                    channels: 3,
                    background: { r: 255, g: 1, b: 255 }
                  }
                })
                  .toFile(`./job_tmp.png`)
// no problem here
                    height: 200100,
// can't open it

@lovell
Copy link
Owner

lovell commented Apr 7, 2021

When you say "can't open it", what tool(s) are you using? Here's the output from the above code when I run it locally, which displays correctly in Chrome and Firefox:

https://user-images.githubusercontent.com/210965/113830428-83edb800-977e-11eb-95fb-4a0614365c56.png

@mclxly
Copy link
Author

mclxly commented Apr 7, 2021

Sorry, you are right, it can be opened by Chrome.

It can't open with default preview tool on macOS Big Sur.

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

No branches or pull requests

2 participants