mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure boolean, bandbool, extractChannel ops occur before sRGB conversion (#504)
This commit is contained in:
committed by
Lovell Fuller
parent
2d500554c1
commit
15a577863a
@@ -774,20 +774,6 @@ class PipelineWorker : public AsyncWorker {
|
||||
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
|
||||
if (baton->booleanOp != VIPS_OPERATION_BOOLEAN_LAST &&
|
||||
(baton->booleanBufferInLength > 0 || !baton->booleanFileIn.empty())) {
|
||||
@@ -840,6 +826,20 @@ class PipelineWorker : public AsyncWorker {
|
||||
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
|
||||
if (baton->withMetadata && baton->withMetadataOrientation != -1) {
|
||||
SetExifOrientation(image, baton->withMetadataOrientation);
|
||||
|
||||
Reference in New Issue
Block a user