mirror of
https://github.com/lovell/sharp.git
synced 2025-12-06 03:51:40 +01:00
Add support for BigTIFF output (#4459)
This commit is contained in:
parent
54722dd582
commit
6b922b30d5
@ -646,6 +646,7 @@ instead of providing `xres` and `yres` in pixels/mm.
|
|||||||
| [options.quality] | <code>number</code> | <code>80</code> | quality, integer 1-100 |
|
| [options.quality] | <code>number</code> | <code>80</code> | quality, integer 1-100 |
|
||||||
| [options.force] | <code>boolean</code> | <code>true</code> | force TIFF output, otherwise attempt to use input format |
|
| [options.force] | <code>boolean</code> | <code>true</code> | force TIFF output, otherwise attempt to use input format |
|
||||||
| [options.compression] | <code>string</code> | <code>"'jpeg'"</code> | compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k |
|
| [options.compression] | <code>string</code> | <code>"'jpeg'"</code> | compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k |
|
||||||
|
| [options.bigtiff] | <code>boolean</code> | <code>false</code> | use BigTIFF variant (has no effect when compression is none) |
|
||||||
| [options.predictor] | <code>string</code> | <code>"'horizontal'"</code> | compression predictor options: none, horizontal, float |
|
| [options.predictor] | <code>string</code> | <code>"'horizontal'"</code> | compression predictor options: none, horizontal, float |
|
||||||
| [options.pyramid] | <code>boolean</code> | <code>false</code> | write an image pyramid |
|
| [options.pyramid] | <code>boolean</code> | <code>false</code> | write an image pyramid |
|
||||||
| [options.tile] | <code>boolean</code> | <code>false</code> | write a tiled tiff |
|
| [options.tile] | <code>boolean</code> | <code>false</code> | write a tiled tiff |
|
||||||
|
|||||||
@ -352,6 +352,7 @@ const Sharp = function (input, options) {
|
|||||||
gifProgressive: false,
|
gifProgressive: false,
|
||||||
tiffQuality: 80,
|
tiffQuality: 80,
|
||||||
tiffCompression: 'jpeg',
|
tiffCompression: 'jpeg',
|
||||||
|
tiffBigtiff: false,
|
||||||
tiffPredictor: 'horizontal',
|
tiffPredictor: 'horizontal',
|
||||||
tiffPyramid: false,
|
tiffPyramid: false,
|
||||||
tiffMiniswhite: false,
|
tiffMiniswhite: false,
|
||||||
|
|||||||
2
lib/index.d.ts
vendored
2
lib/index.d.ts
vendored
@ -1460,6 +1460,8 @@ declare namespace sharp {
|
|||||||
quality?: number | undefined;
|
quality?: number | undefined;
|
||||||
/** Compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k (optional, default 'jpeg') */
|
/** Compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k (optional, default 'jpeg') */
|
||||||
compression?: string | undefined;
|
compression?: string | undefined;
|
||||||
|
/** Use BigTIFF variant (has no effect when compression is none) (optional, default false) */
|
||||||
|
bigtiff?: boolean | undefined;
|
||||||
/** Compression predictor options: none, horizontal, float (optional, default 'horizontal') */
|
/** Compression predictor options: none, horizontal, float (optional, default 'horizontal') */
|
||||||
predictor?: string | undefined;
|
predictor?: string | undefined;
|
||||||
/** Write an image pyramid (optional, default false) */
|
/** Write an image pyramid (optional, default false) */
|
||||||
|
|||||||
@ -974,6 +974,7 @@ function trySetAnimationOptions (source, target) {
|
|||||||
* @param {number} [options.quality=80] - quality, integer 1-100
|
* @param {number} [options.quality=80] - quality, integer 1-100
|
||||||
* @param {boolean} [options.force=true] - force TIFF output, otherwise attempt to use input format
|
* @param {boolean} [options.force=true] - force TIFF output, otherwise attempt to use input format
|
||||||
* @param {string} [options.compression='jpeg'] - compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k
|
* @param {string} [options.compression='jpeg'] - compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k
|
||||||
|
* @param {boolean} [options.bigtiff=false] - use BigTIFF variant (has no effect when compression is none)
|
||||||
* @param {string} [options.predictor='horizontal'] - compression predictor options: none, horizontal, float
|
* @param {string} [options.predictor='horizontal'] - compression predictor options: none, horizontal, float
|
||||||
* @param {boolean} [options.pyramid=false] - write an image pyramid
|
* @param {boolean} [options.pyramid=false] - write an image pyramid
|
||||||
* @param {boolean} [options.tile=false] - write a tiled tiff
|
* @param {boolean} [options.tile=false] - write a tiled tiff
|
||||||
@ -1052,6 +1053,10 @@ function tiff (options) {
|
|||||||
throw is.invalidParameterError('compression', 'one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k', options.compression);
|
throw is.invalidParameterError('compression', 'one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k', options.compression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// bigtiff
|
||||||
|
if (is.defined(options.bigtiff)) {
|
||||||
|
this._setBooleanOption('tiffBigtiff', options.bigtiff);
|
||||||
|
}
|
||||||
// predictor
|
// predictor
|
||||||
if (is.defined(options.predictor)) {
|
if (is.defined(options.predictor)) {
|
||||||
if (is.string(options.predictor) && is.inArray(options.predictor, ['none', 'horizontal', 'float'])) {
|
if (is.string(options.predictor) && is.inArray(options.predictor, ['none', 'horizontal', 'float'])) {
|
||||||
|
|||||||
@ -1009,6 +1009,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("bigtiff", baton->tiffBigtiff)
|
||||||
->set("miniswhite", baton->tiffMiniswhite)
|
->set("miniswhite", baton->tiffMiniswhite)
|
||||||
->set("predictor", baton->tiffPredictor)
|
->set("predictor", baton->tiffPredictor)
|
||||||
->set("pyramid", baton->tiffPyramid)
|
->set("pyramid", baton->tiffPyramid)
|
||||||
@ -1211,6 +1212,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("bigtiff", baton->tiffBigtiff)
|
||||||
->set("miniswhite", baton->tiffMiniswhite)
|
->set("miniswhite", baton->tiffMiniswhite)
|
||||||
->set("predictor", baton->tiffPredictor)
|
->set("predictor", baton->tiffPredictor)
|
||||||
->set("pyramid", baton->tiffPyramid)
|
->set("pyramid", baton->tiffPyramid)
|
||||||
@ -1750,6 +1752,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
|||||||
baton->gifReuse = sharp::AttrAsBool(options, "gifReuse");
|
baton->gifReuse = sharp::AttrAsBool(options, "gifReuse");
|
||||||
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->tiffBigtiff = sharp::AttrAsBool(options, "tiffBigtiff");
|
||||||
baton->tiffPyramid = sharp::AttrAsBool(options, "tiffPyramid");
|
baton->tiffPyramid = sharp::AttrAsBool(options, "tiffPyramid");
|
||||||
baton->tiffMiniswhite = sharp::AttrAsBool(options, "tiffMiniswhite");
|
baton->tiffMiniswhite = sharp::AttrAsBool(options, "tiffMiniswhite");
|
||||||
baton->tiffBitdepth = sharp::AttrAsUint32(options, "tiffBitdepth");
|
baton->tiffBitdepth = sharp::AttrAsUint32(options, "tiffBitdepth");
|
||||||
|
|||||||
@ -175,6 +175,7 @@ struct PipelineBaton {
|
|||||||
bool gifProgressive;
|
bool gifProgressive;
|
||||||
int tiffQuality;
|
int tiffQuality;
|
||||||
VipsForeignTiffCompression tiffCompression;
|
VipsForeignTiffCompression tiffCompression;
|
||||||
|
bool tiffBigtiff;
|
||||||
VipsForeignTiffPredictor tiffPredictor;
|
VipsForeignTiffPredictor tiffPredictor;
|
||||||
bool tiffPyramid;
|
bool tiffPyramid;
|
||||||
int tiffBitdepth;
|
int tiffBitdepth;
|
||||||
@ -350,6 +351,7 @@ struct PipelineBaton {
|
|||||||
gifProgressive(false),
|
gifProgressive(false),
|
||||||
tiffQuality(80),
|
tiffQuality(80),
|
||||||
tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
|
tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
|
||||||
|
tiffBigtiff(false),
|
||||||
tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
|
tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
|
||||||
tiffPyramid(false),
|
tiffPyramid(false),
|
||||||
tiffBitdepth(8),
|
tiffBitdepth(8),
|
||||||
|
|||||||
@ -401,6 +401,18 @@ describe('TIFF', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('TIFF bigtiff true value does not throw error', function () {
|
||||||
|
assert.doesNotThrow(function () {
|
||||||
|
sharp().tiff({ bigtiff: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Invalid TIFF bigtiff value throws error', function () {
|
||||||
|
assert.throws(function () {
|
||||||
|
sharp().tiff({ bigtiff: 'true' });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('TIFF invalid predictor option throws', function () {
|
it('TIFF invalid predictor option throws', function () {
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
sharp().tiff({ predictor: 'a' });
|
sharp().tiff({ predictor: 'a' });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user