mirror of
https://github.com/lovell/sharp.git
synced 2025-07-12 12:00:14 +02:00
Ensure TIFF is cast when using float predictor (#2502)
This commit is contained in:
parent
98349bde28
commit
0bb8cb9203
@ -6,6 +6,10 @@ Requires libvips v8.10.5
|
||||
|
||||
### v0.27.1 - TBD
|
||||
|
||||
* Ensure TIFF is cast when using float predictor.
|
||||
[#2502](https://github.com/lovell/sharp/pull/2502)
|
||||
[@randyridge](https://github.com/randyridge)
|
||||
|
||||
* Add support for Uint8Array and Uint8ClampedArray input.
|
||||
[#2511](https://github.com/lovell/sharp/pull/2511)
|
||||
[@leon](https://github.com/leon)
|
||||
|
@ -955,6 +955,10 @@ class PipelineWorker : public Napi::AsyncWorker {
|
||||
sharp::AssertImageTypeDimensions(image, sharp::ImageType::JPEG);
|
||||
baton->channels = std::min(baton->channels, 3);
|
||||
}
|
||||
// Cast pixel values to float, if required
|
||||
if (baton->tiffPredictor == VIPS_FOREIGN_TIFF_PREDICTOR_FLOAT) {
|
||||
image = image.cast(VIPS_FORMAT_FLOAT);
|
||||
}
|
||||
image.tiffsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
|
||||
->set("strip", !baton->withMetadata)
|
||||
->set("Q", baton->tiffQuality)
|
||||
|
@ -277,7 +277,7 @@ describe('TIFF', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('TIFF deflate compression with float predictor shrinks test file', function (done) {
|
||||
it('TIFF deflate compression of integral input with float predictor increases file size', function (done) {
|
||||
const startSize = fs.statSync(fixtures.inputTiffUncompressed).size;
|
||||
sharp(fixtures.inputTiffUncompressed)
|
||||
.tiff({
|
||||
@ -287,7 +287,7 @@ describe('TIFF', function () {
|
||||
.toFile(fixtures.outputTiff, (err, info) => {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('tiff', info.format);
|
||||
assert(info.size < startSize);
|
||||
assert(info.size > startSize);
|
||||
rimraf(fixtures.outputTiff, done);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user