Skip to content

limitInputPixels should probably be 53-bit integer #3238

@AndrewJDR

Description

@AndrewJDR

src/common.h and src/common.cc show that limitInputPixels is an int, but pixel counts can certainly exceed this (e.g. inputs for tile()) while still perhaps being worthy of some limiting, so ideally you could still set limits above 2^31 or 2^32.

Activity

lovell

lovell commented on May 25, 2022

@lovell
Owner

This would require support for the BigInt data type, which was added to Node-API v6.

This means we'll need to wait until we drop support for Node.js 12, probably the forthcoming v0.31.0 release, then we can bump the minimum Node-API version from v5 to v6 (or v7) and consider adding this feature.

https://nodejs.org/dist/latest/docs/api/n-api.html#node-api-version-matrix

added this to the v0.31.0 milestone on May 25, 2022
AndrewJDR

AndrewJDR commented on May 25, 2022

@AndrewJDR
Author

@lovell Isn't napi_create_int64() (since node v8.4.0) sufficient?

lovell

lovell commented on May 25, 2022

@lovell
Owner

That would provide support for 53-bit integers, which is a wider range than 32-bit, but to support your request for 64-bit integers we'll need BigInt.

AndrewJDR

AndrewJDR commented on May 26, 2022

@AndrewJDR
Author

Ah, sure... 53-bit is more than sufficient for this purpose, in my opinion -- I can revise it.

changed the title [-]limitInputPixels should probably be 64-bit integer[/-] [+]limitInputPixels should probably be 53-bit integer[/+] on May 26, 2022
lovell

lovell commented on May 26, 2022

@lovell
Owner

Great, thanks for the update, this might be a good time to roll out the :why_not_both: meme! 😄

AndrewJDR

AndrewJDR commented on May 26, 2022

@AndrewJDR
Author

Oh, I should also mention -- if you pass a number >= 2^32 (or likely even >= 2^31, since it's signed under the hood) you'll get the Input image exceeds pixel limit error on images sized smaller than the number you passed. This was initially mystifying until I had a look at the code. And I didn't test for this, but I presume anything >= 2^31 overflows and you end up with some arbitrary number between -(2^31) ... 2^31. Anyhow, this is a long way of saying some type of overflow warning/error or documentation might be good, though it's less necessary once there is 53/64 bit support... I don't think many will run into it after that.

5 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @lovell@AndrewJDR

        Issue actions

          limitInputPixels should probably be 53-bit integer · Issue #3238 · lovell/sharp