Impute TIFF xres/yres from withMetadata({density})

This commit is contained in:
Michael B. Klein
2021-10-28 14:46:45 -05:00
committed by Lovell Fuller
parent b33231d4bd
commit 342de36973
5 changed files with 28 additions and 1 deletions

View File

@@ -188,6 +188,26 @@ describe('TIFF', function () {
)
);
it('TIFF imputes xres and yres from withMetadataDensity if not explicitly provided', async () => {
const data = await sharp(fixtures.inputTiff)
.resize(8, 8)
.tiff()
.withMetadata({ density: 600 })
.toBuffer();
const { density } = await sharp(data).metadata();
assert.strictEqual(600, density);
});
it('TIFF uses xres and yres over withMetadataDensity if explicitly provided', async () => {
const data = await sharp(fixtures.inputTiff)
.resize(8, 8)
.tiff({ xres: 1000, yres: 1000 })
.withMetadata({ density: 600 })
.toBuffer();
const { density } = await sharp(data).metadata();
assert.strictEqual(25400, density);
});
it('TIFF invalid xres value should throw an error', function () {
assert.throws(function () {
sharp().tiff({ xres: '1000.0' });