mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add resolutionUnit to metadata and as tiff option #3023
Co-authored-by: Lovell Fuller <github@lovell.info>
This commit is contained in:
@@ -288,6 +288,30 @@ describe('TIFF', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('TIFF resolutionUnit of inch (default)', async () => {
|
||||
const data = await sharp({ create: { width: 8, height: 8, channels: 3, background: 'red' } })
|
||||
.tiff()
|
||||
.toBuffer();
|
||||
const { resolutionUnit } = await sharp(data).metadata();
|
||||
assert.strictEqual(resolutionUnit, 'inch');
|
||||
});
|
||||
|
||||
it('TIFF resolutionUnit of inch', async () => {
|
||||
const data = await sharp({ create: { width: 8, height: 8, channels: 3, background: 'red' } })
|
||||
.tiff({ resolutionUnit: 'inch' })
|
||||
.toBuffer();
|
||||
const { resolutionUnit } = await sharp(data).metadata();
|
||||
assert.strictEqual(resolutionUnit, 'inch');
|
||||
});
|
||||
|
||||
it('TIFF resolutionUnit of cm', async () => {
|
||||
const data = await sharp({ create: { width: 8, height: 8, channels: 3, background: 'red' } })
|
||||
.tiff({ resolutionUnit: 'cm' })
|
||||
.toBuffer();
|
||||
const { resolutionUnit } = await sharp(data).metadata();
|
||||
assert.strictEqual(resolutionUnit, 'cm');
|
||||
});
|
||||
|
||||
it('TIFF deflate compression with horizontal predictor shrinks test file', function (done) {
|
||||
const startSize = fs.statSync(fixtures.inputTiffUncompressed).size;
|
||||
sharp(fixtures.inputTiffUncompressed)
|
||||
@@ -383,6 +407,12 @@ describe('TIFF', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('TIFF invalid resolutionUnit option throws', function () {
|
||||
assert.throws(function () {
|
||||
sharp().tiff({ resolutionUnit: 'none' });
|
||||
});
|
||||
});
|
||||
|
||||
it('TIFF horizontal predictor does not throw error', function () {
|
||||
assert.doesNotThrow(function () {
|
||||
sharp().tiff({ predictor: 'horizontal' });
|
||||
|
||||
Reference in New Issue
Block a user