mirror of
https://github.com/lovell/sharp.git
synced 2025-07-13 12:20:13 +02:00
Ensure boolean, bandbool, extractChannel ops occur before sRGB conversion (#504)
This commit is contained in:
parent
2d500554c1
commit
15a577863a
@ -774,20 +774,6 @@ class PipelineWorker : public AsyncWorker {
|
|||||||
image = Normalize(image);
|
image = Normalize(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert image to sRGB, if not already
|
|
||||||
if (Is16Bit(image.interpretation())) {
|
|
||||||
image = image.cast(VIPS_FORMAT_USHORT);
|
|
||||||
}
|
|
||||||
if (image.interpretation() != VIPS_INTERPRETATION_sRGB) {
|
|
||||||
image = image.colourspace(VIPS_INTERPRETATION_sRGB);
|
|
||||||
// Transform colours from embedded profile to sRGB profile
|
|
||||||
if (baton->withMetadata && HasProfile(image)) {
|
|
||||||
image = image.icc_transform(const_cast<char*>(srgbProfile.data()), VImage::option()
|
|
||||||
->set("embedded", TRUE)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply bitwise boolean operation between images
|
// Apply bitwise boolean operation between images
|
||||||
if (baton->booleanOp != VIPS_OPERATION_BOOLEAN_LAST &&
|
if (baton->booleanOp != VIPS_OPERATION_BOOLEAN_LAST &&
|
||||||
(baton->booleanBufferInLength > 0 || !baton->booleanFileIn.empty())) {
|
(baton->booleanBufferInLength > 0 || !baton->booleanFileIn.empty())) {
|
||||||
@ -840,6 +826,20 @@ class PipelineWorker : public AsyncWorker {
|
|||||||
image = image.extract_band(baton->extractChannel);
|
image = image.extract_band(baton->extractChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert image to sRGB, if not already
|
||||||
|
if (Is16Bit(image.interpretation())) {
|
||||||
|
image = image.cast(VIPS_FORMAT_USHORT);
|
||||||
|
}
|
||||||
|
if (image.interpretation() != VIPS_INTERPRETATION_sRGB) {
|
||||||
|
image = image.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
|
// Transform colours from embedded profile to sRGB profile
|
||||||
|
if (baton->withMetadata && HasProfile(image)) {
|
||||||
|
image = image.icc_transform(const_cast<char*>(srgbProfile.data()), VImage::option()
|
||||||
|
->set("embedded", TRUE)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Override EXIF Orientation tag
|
// Override EXIF Orientation tag
|
||||||
if (baton->withMetadata && baton->withMetadataOrientation != -1) {
|
if (baton->withMetadata && baton->withMetadataOrientation != -1) {
|
||||||
SetExifOrientation(image, baton->withMetadataOrientation);
|
SetExifOrientation(image, baton->withMetadataOrientation);
|
||||||
|
@ -69,4 +69,13 @@ describe('Image channel extraction', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Non-existant channel', function(done) {
|
||||||
|
sharp(fixtures.inputPng)
|
||||||
|
.extractChannel(1)
|
||||||
|
.toBuffer(function(err) {
|
||||||
|
assert(err instanceof Error);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user