mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Convert image to sRGB sooner for embed
This commit is contained in:
parent
2605bf966f
commit
945d941c7b
13
src/sharp.cc
13
src/sharp.cc
@ -545,7 +545,7 @@ class ResizeWorker : public NanAsyncWorker {
|
|||||||
// Convert to sRGB colour space
|
// Convert to sRGB colour space
|
||||||
VipsImage *colourspaced = vips_image_new();
|
VipsImage *colourspaced = vips_image_new();
|
||||||
vips_object_local(hook, colourspaced);
|
vips_object_local(hook, colourspaced);
|
||||||
if (vips_colourspace(profile, &colourspaced, VIPS_INTERPRETATION_sRGB, NULL)) {
|
if (vips_colourspace(image, &colourspaced, VIPS_INTERPRETATION_sRGB, NULL)) {
|
||||||
return resize_error(baton, hook);
|
return resize_error(baton, hook);
|
||||||
}
|
}
|
||||||
g_object_unref(image);
|
g_object_unref(image);
|
||||||
@ -653,6 +653,17 @@ class ResizeWorker : public NanAsyncWorker {
|
|||||||
VipsImage *canvased = vips_image_new();
|
VipsImage *canvased = vips_image_new();
|
||||||
vips_object_local(hook, canvased);
|
vips_object_local(hook, canvased);
|
||||||
if (baton->canvas == EMBED) {
|
if (baton->canvas == EMBED) {
|
||||||
|
// Match background colour space, namely sRGB
|
||||||
|
if (image->Type != VIPS_INTERPRETATION_sRGB) {
|
||||||
|
// Convert to sRGB colour space
|
||||||
|
VipsImage *colourspaced = vips_image_new();
|
||||||
|
vips_object_local(hook, colourspaced);
|
||||||
|
if (vips_colourspace(image, &colourspaced, VIPS_INTERPRETATION_sRGB, NULL)) {
|
||||||
|
return resize_error(baton, hook);
|
||||||
|
}
|
||||||
|
g_object_unref(image);
|
||||||
|
image = colourspaced;
|
||||||
|
}
|
||||||
// Add non-transparent alpha channel, if required
|
// Add non-transparent alpha channel, if required
|
||||||
if (baton->background[3] < 255.0 && !sharp_image_has_alpha(image)) {
|
if (baton->background[3] < 255.0 && !sharp_image_has_alpha(image)) {
|
||||||
// Create single-channel transparency
|
// Create single-channel transparency
|
||||||
|
Loading…
x
Reference in New Issue
Block a user