Add support for libvips JPEG 2000 one-shot load option #4262
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Last month, I reported an issue (libvips/libvips#4205) to libvips regarding errors loading certain JPEG 2000 files. The core issue is in the OpenJPEG library itself, and the issue has been reported there as well (uclouvain/openjpeg#1558). In short, when the source image is a JPEG 2000 image with more than one tile and more than one tile-part per tile, OpenJPEG will throw an error immediately upon trying to access the second tile in a given operation.
Until the upstream issue is addressed, the only good workaround seems to be to have libvips load the entire image in one shot instead of tile by tile. This feature has been added in a branch, with the expectation that it will be released as part of libvips 8.17 in a few months' time.
In the meantime, I thought I would create this PR so that you can evaluate the interface, option name, etc. and request any changes before the time comes to support the new option. I've included a derivative copy of the
relax.jp2
test fixture,relax_tileparts.jp2
, which includes the problematic tile layout.Demonstration of the issue and the proposed workaround, using a version of sharp built with OpenJPEG v2.5.2 and the libvips branch linked above: