Skip to content

Commit

Permalink
Allow use of 'tif' to select TIFF output (#2893)
Browse files Browse the repository at this point in the history
  • Loading branch information
erf authored Sep 16, 2021
1 parent 481e350 commit 2679bb5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const formats = new Map([
['png', 'png'],
['raw', 'raw'],
['tiff', 'tiff'],
['tif', 'tiff'],
['webp', 'webp'],
['gif', 'gif'],
['jp2', 'jp2'],
Expand Down
15 changes: 15 additions & 0 deletions test/unit/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,21 @@ describe('Input/output', function () {
});
});

it('Support output to tif format', function (done) {
sharp(fixtures.inputTiff)
.resize(320, 240)
.toFormat('tif')
.toBuffer(function (err, data, info) {
if (err) throw err;
assert.strictEqual(true, data.length > 0);
assert.strictEqual(data.length, info.size);
assert.strictEqual('tiff', info.format);
assert.strictEqual(320, info.width);
assert.strictEqual(240, info.height);
done();
});
});

it('Fail when output File is input File', function (done) {
sharp(fixtures.inputJpg).toFile(fixtures.inputJpg, function (err) {
assert(err instanceof Error);
Expand Down

0 comments on commit 2679bb5

Please sign in to comment.