Ensure boolean, bandbool, extractChannel ops occur before sRGB conversion (#504)

This commit is contained in:
Matt Hirsch
2016-07-13 14:20:50 -04:00
committed by Lovell Fuller
parent 2d500554c1
commit 15a577863a
2 changed files with 23 additions and 14 deletions

View File

@@ -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);