mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Add support for miniswhite when using TIFF output
This commit is contained in:
parent
0f24f0f214
commit
28aa176957
@ -466,6 +466,7 @@ instead of providing `xres` and `yres` in pixels/mm.
|
|||||||
| [options.yres] | <code>number</code> | <code>1.0</code> | vertical resolution in pixels/mm |
|
| [options.yres] | <code>number</code> | <code>1.0</code> | vertical resolution in pixels/mm |
|
||||||
| [options.resolutionUnit] | <code>string</code> | <code>"'inch'"</code> | resolution unit options: inch, cm |
|
| [options.resolutionUnit] | <code>string</code> | <code>"'inch'"</code> | resolution unit options: inch, cm |
|
||||||
| [options.bitdepth] | <code>number</code> | <code>8</code> | reduce bitdepth to 1, 2 or 4 bit |
|
| [options.bitdepth] | <code>number</code> | <code>8</code> | reduce bitdepth to 1, 2 or 4 bit |
|
||||||
|
| [options.miniswhite] | <code>boolean</code> | <code>false</code> | write 1-bit images as miniswhite |
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
```js
|
```js
|
||||||
|
File diff suppressed because one or more lines are too long
@ -305,6 +305,7 @@ const Sharp = function (input, options) {
|
|||||||
tiffCompression: 'jpeg',
|
tiffCompression: 'jpeg',
|
||||||
tiffPredictor: 'horizontal',
|
tiffPredictor: 'horizontal',
|
||||||
tiffPyramid: false,
|
tiffPyramid: false,
|
||||||
|
tiffMiniswhite: false,
|
||||||
tiffBitdepth: 8,
|
tiffBitdepth: 8,
|
||||||
tiffTile: false,
|
tiffTile: false,
|
||||||
tiffTileHeight: 256,
|
tiffTileHeight: 256,
|
||||||
|
2
lib/index.d.ts
vendored
2
lib/index.d.ts
vendored
@ -1234,6 +1234,8 @@ declare namespace sharp {
|
|||||||
yres?: number | undefined;
|
yres?: number | undefined;
|
||||||
/** Reduce bitdepth to 1, 2 or 4 bit (optional, default 8) */
|
/** Reduce bitdepth to 1, 2 or 4 bit (optional, default 8) */
|
||||||
bitdepth?: 1 | 2 | 4 | 8 | undefined;
|
bitdepth?: 1 | 2 | 4 | 8 | undefined;
|
||||||
|
/** Write 1-bit images as miniswhite (optional, default false) */
|
||||||
|
miniswhite?: boolean | undefined;
|
||||||
/** Resolution unit options: inch, cm (optional, default 'inch') */
|
/** Resolution unit options: inch, cm (optional, default 'inch') */
|
||||||
resolutionUnit?: 'inch' | 'cm' | undefined;
|
resolutionUnit?: 'inch' | 'cm' | undefined;
|
||||||
}
|
}
|
||||||
|
@ -782,6 +782,7 @@ function trySetAnimationOptions (source, target) {
|
|||||||
* @param {number} [options.yres=1.0] - vertical resolution in pixels/mm
|
* @param {number} [options.yres=1.0] - vertical resolution in pixels/mm
|
||||||
* @param {string} [options.resolutionUnit='inch'] - resolution unit options: inch, cm
|
* @param {string} [options.resolutionUnit='inch'] - resolution unit options: inch, cm
|
||||||
* @param {number} [options.bitdepth=8] - reduce bitdepth to 1, 2 or 4 bit
|
* @param {number} [options.bitdepth=8] - reduce bitdepth to 1, 2 or 4 bit
|
||||||
|
* @param {boolean} [options.miniswhite=false] - write 1-bit images as miniswhite
|
||||||
* @returns {Sharp}
|
* @returns {Sharp}
|
||||||
* @throws {Error} Invalid options
|
* @throws {Error} Invalid options
|
||||||
*/
|
*/
|
||||||
@ -819,6 +820,10 @@ function tiff (options) {
|
|||||||
throw is.invalidParameterError('tileHeight', 'integer greater than zero', options.tileHeight);
|
throw is.invalidParameterError('tileHeight', 'integer greater than zero', options.tileHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// miniswhite
|
||||||
|
if (is.defined(options.miniswhite)) {
|
||||||
|
this._setBooleanOption('tiffMiniswhite', options.miniswhite);
|
||||||
|
}
|
||||||
// pyramid
|
// pyramid
|
||||||
if (is.defined(options.pyramid)) {
|
if (is.defined(options.pyramid)) {
|
||||||
this._setBooleanOption('tiffPyramid', options.pyramid);
|
this._setBooleanOption('tiffPyramid', options.pyramid);
|
||||||
|
@ -86,7 +86,8 @@
|
|||||||
"Ankur Parihar <ankur.github@gmail.com>",
|
"Ankur Parihar <ankur.github@gmail.com>",
|
||||||
"Brahim Ait elhaj <brahima@gmail.com>",
|
"Brahim Ait elhaj <brahima@gmail.com>",
|
||||||
"Mart Jansink <m.jansink@gmail.com>",
|
"Mart Jansink <m.jansink@gmail.com>",
|
||||||
"Lachlan Newman <lachnewman007@gmail.com>"
|
"Lachlan Newman <lachnewman007@gmail.com>",
|
||||||
|
"Dennis Beatty <dennis@dcbeatty.com>"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "node install/check",
|
"install": "node install/check",
|
||||||
|
@ -940,6 +940,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
->set("Q", baton->tiffQuality)
|
->set("Q", baton->tiffQuality)
|
||||||
->set("bitdepth", baton->tiffBitdepth)
|
->set("bitdepth", baton->tiffBitdepth)
|
||||||
->set("compression", baton->tiffCompression)
|
->set("compression", baton->tiffCompression)
|
||||||
|
->set("miniswhite", baton->tiffMiniswhite)
|
||||||
->set("predictor", baton->tiffPredictor)
|
->set("predictor", baton->tiffPredictor)
|
||||||
->set("pyramid", baton->tiffPyramid)
|
->set("pyramid", baton->tiffPyramid)
|
||||||
->set("tile", baton->tiffTile)
|
->set("tile", baton->tiffTile)
|
||||||
@ -1136,6 +1137,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
->set("Q", baton->tiffQuality)
|
->set("Q", baton->tiffQuality)
|
||||||
->set("bitdepth", baton->tiffBitdepth)
|
->set("bitdepth", baton->tiffBitdepth)
|
||||||
->set("compression", baton->tiffCompression)
|
->set("compression", baton->tiffCompression)
|
||||||
|
->set("miniswhite", baton->tiffMiniswhite)
|
||||||
->set("predictor", baton->tiffPredictor)
|
->set("predictor", baton->tiffPredictor)
|
||||||
->set("pyramid", baton->tiffPyramid)
|
->set("pyramid", baton->tiffPyramid)
|
||||||
->set("tile", baton->tiffTile)
|
->set("tile", baton->tiffTile)
|
||||||
@ -1647,6 +1649,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
|||||||
baton->gifProgressive = sharp::AttrAsBool(options, "gifProgressive");
|
baton->gifProgressive = sharp::AttrAsBool(options, "gifProgressive");
|
||||||
baton->tiffQuality = sharp::AttrAsUint32(options, "tiffQuality");
|
baton->tiffQuality = sharp::AttrAsUint32(options, "tiffQuality");
|
||||||
baton->tiffPyramid = sharp::AttrAsBool(options, "tiffPyramid");
|
baton->tiffPyramid = sharp::AttrAsBool(options, "tiffPyramid");
|
||||||
|
baton->tiffMiniswhite = sharp::AttrAsBool(options, "tiffMiniswhite");
|
||||||
baton->tiffBitdepth = sharp::AttrAsUint32(options, "tiffBitdepth");
|
baton->tiffBitdepth = sharp::AttrAsUint32(options, "tiffBitdepth");
|
||||||
baton->tiffTile = sharp::AttrAsBool(options, "tiffTile");
|
baton->tiffTile = sharp::AttrAsBool(options, "tiffTile");
|
||||||
baton->tiffTileWidth = sharp::AttrAsUint32(options, "tiffTileWidth");
|
baton->tiffTileWidth = sharp::AttrAsUint32(options, "tiffTileWidth");
|
||||||
|
@ -169,6 +169,7 @@ struct PipelineBaton {
|
|||||||
VipsForeignTiffPredictor tiffPredictor;
|
VipsForeignTiffPredictor tiffPredictor;
|
||||||
bool tiffPyramid;
|
bool tiffPyramid;
|
||||||
int tiffBitdepth;
|
int tiffBitdepth;
|
||||||
|
bool tiffMiniswhite;
|
||||||
bool tiffTile;
|
bool tiffTile;
|
||||||
int tiffTileHeight;
|
int tiffTileHeight;
|
||||||
int tiffTileWidth;
|
int tiffTileWidth;
|
||||||
@ -335,6 +336,7 @@ struct PipelineBaton {
|
|||||||
tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
|
tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
|
||||||
tiffPyramid(false),
|
tiffPyramid(false),
|
||||||
tiffBitdepth(8),
|
tiffBitdepth(8),
|
||||||
|
tiffMiniswhite(false),
|
||||||
tiffTile(false),
|
tiffTile(false),
|
||||||
tiffTileHeight(256),
|
tiffTileHeight(256),
|
||||||
tiffTileWidth(256),
|
tiffTileWidth(256),
|
||||||
|
@ -462,6 +462,18 @@ describe('TIFF', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('TIFF miniswhite true value does not throw error', function () {
|
||||||
|
assert.doesNotThrow(function () {
|
||||||
|
sharp().tiff({ miniswhite: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Invalid TIFF miniswhite value throws error', function () {
|
||||||
|
assert.throws(function () {
|
||||||
|
sharp().tiff({ miniswhite: 'true' });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Invalid TIFF tile value throws error', function () {
|
it('Invalid TIFF tile value throws error', function () {
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
sharp().tiff({ tile: 'true' });
|
sharp().tiff({ tile: 'true' });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user