mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Expose JPEG 2000 oneshot decoder option #4262
Requires libvips compiled with support for JP2 images Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
This commit is contained in:
committed by
Lovell Fuller
parent
01f6cbbaee
commit
751f9992c4
@@ -93,10 +93,38 @@ describe('JP2 output', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid JP2 chromaSubsampling value throws error', function () {
|
||||
assert.throws(function () {
|
||||
sharp().jpeg({ chromaSubsampling: '4:2:2' });
|
||||
it('can use the jp2Oneshot option to handle multi-part tiled JPEG 2000 file', async () => {
|
||||
const outputJpg = fixtures.path('output.jpg');
|
||||
await assert.rejects(
|
||||
() => sharp(fixtures.inputJp2TileParts).toFile(outputJpg)
|
||||
);
|
||||
await assert.doesNotReject(async () => {
|
||||
await sharp(fixtures.inputJp2TileParts, { jp2Oneshot: true }).toFile(outputJpg);
|
||||
const { format, width, height } = await sharp(outputJpg).metadata();
|
||||
assert.strictEqual(format, 'jpeg');
|
||||
assert.strictEqual(width, 320);
|
||||
assert.strictEqual(height, 240);
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid JP2 chromaSubsampling value throws error', () => {
|
||||
assert.throws(
|
||||
() => sharp().jp2({ chromaSubsampling: '4:2:2' }),
|
||||
/Expected one of 4:2:0, 4:4:4 but received 4:2:2 of type string/
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
it('valid JP2 oneshot value does not throw error', () => {
|
||||
assert.doesNotThrow(
|
||||
() => sharp(fixtures.inputJp2TileParts, { jp2Oneshot: true })
|
||||
);
|
||||
});
|
||||
|
||||
it('invalid JP2 oneshot value throws error', () => {
|
||||
assert.throws(
|
||||
() => sharp(fixtures.inputJp2TileParts, { jp2Oneshot: 'fail' }),
|
||||
/Expected boolean for jp2Oneshot but received fail of type string/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user