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

resize width is limited to 16383 #176

Closed
stephanebachelier opened this issue Mar 5, 2015 · 13 comments
Closed

resize width is limited to 16383 #176

stephanebachelier opened this issue Mar 5, 2015 · 13 comments
Milestone

Comments

@stephanebachelier
Copy link

I need to resize an image to 16384*16384 with is 2^14 but sharp maximum width is set to 0x3FFF = 16383.

Have you an idea why this limit and if I can override it.

@lovell
Copy link
Owner

lovell commented Mar 5, 2015

Hi Stéphane, the <=16383 limit is due to the lowest common denominator of WebP storing each dimension in 14 bits.

To increase this we'd need to switch from a generic hard limit applied to all formats to instead use per-format limits, e.g. JPEG uses 16 bits, so <= 65535.

At the moment the output format isn't worked out until near the end of the processing pipeline, so this logic should probably move nearer to the start and then have per-format limits applied.

@stephanebachelier
Copy link
Author

@lovell thanks for your explanations.
This means that I could not have a JPEG larger than 65535, which is huge I know but when working on map tiles you can have really large images.

You might help and tell me what strategy is the best between in a memory point of view:

  • resizing down a really large image to e.g. 2^17 (131072) and then extract some part which are resized to 256 px
  • or extract a part and resize.

@lovell
Copy link
Owner

lovell commented Mar 12, 2015

Support for Deep Zoom tile output is imminent (I'll be merging #146 today). Might this help?

@stephanebachelier
Copy link
Author

@lovell not sure. I don't know about Deep Zoom and when reading comments in #146 it seems a deep understanding of libvips is needed.

@lovell
Copy link
Owner

lovell commented Mar 12, 2015

Sorry, the discussion on that PR quickly became quite detailed. The API it adds will (hopefully) be simple.

"when working on map tiles you can have really large images"

If you need to generate map tiles, once the new code is merged you should be able to do something as simple as sharp(largeInput).tile(256).toFile('output.dzi') to generate a "pyramid" of 256x256 JPEG tiles at intermediate /2 zoom levels. This might remove the need to manually resize and extract for your use case.

@stephanebachelier
Copy link
Author

@lovell read the diff was easier to understand the change :)

I didn't know about openslide nor deep zoom and I think #146 might help me.

@lovell
Copy link
Owner

lovell commented Mar 12, 2015

Experimental support for tiled output is now available on the judgement branch:

npm install lovell/sharp#judgement

You'll need to ensure libvips was compiled with support for Deep Zoom (vips installed via homebrew does this already; for Linux install libgsf-1-dev first).

@stephanebachelier
Copy link
Author

@lovell great! I'll test it.
I've already upgraded libvips after reading through #146 patch.

@lovell
Copy link
Owner

lovell commented Jun 30, 2015

@stephanebachelier Do you still require an increase to the minimum width or were you able to use the Deep Zoom tile feature for your map use case?

@stephanebachelier
Copy link
Author

@lovell no the deep zoom tile did not work for me. But I tested it 3 months ago.
Need to test on the new version.

@lovell
Copy link
Owner

lovell commented Mar 6, 2017

Given all the possible combinations of resizing, extraction, rotation etc. operations the final output image dimensions won't be known until the end of the pipeline.

What I propose is to have a per-format check just before writing to the output image, with those limits being:

  • WebP: 16383 x 16383 (14-bit unsigned)
  • JPEG/TIFF: 65535 x 65535 (16-bit unsigned)
  • PNG: 2147483647 x 2147483647 (32-bit signed)

@lovell lovell removed the help wanted label Mar 6, 2017
@lovell lovell added this to the v0.17.3 milestone Mar 6, 2017
@lovell lovell modified the milestones: v0.18.0, v0.17.3 Mar 24, 2017
@lovell
Copy link
Owner

lovell commented May 4, 2017

Commit 2f534dc on the ridge branch removes the hard-coded 2^14 output limit, replacing it with the relevant per-format limit. This will be in v0.18.0

@lovell
Copy link
Owner

lovell commented May 30, 2017

v0.18.0 now available.

@lovell lovell closed this as completed May 30, 2017
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