Skip to content

colour: add support for auto-selecting the rendering intent #4366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- tiffload: add support for fail_on flag [lovell]
- tiffload: add support for unlimited flag (requires libtiff 4.7.0+) [lovell]
- much more reliable operation caching
- colour: add support for auto-selecting the rendering intent [kleisauke]

8.16.1

Expand Down
7 changes: 5 additions & 2 deletions libvips/colour/icc_transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
* @VIPS_INTENT_RELATIVE: relative colorimetric rendering intent
* @VIPS_INTENT_SATURATION: saturation rendering intent
* @VIPS_INTENT_ABSOLUTE: absolute colorimetric rendering intent
* @VIPS_INTENT_AUTO: the rendering intent that the profile suggests
*
* The rendering intent. #VIPS_INTENT_ABSOLUTE is best for
* scientific work, #VIPS_INTENT_RELATIVE is usually best for
Expand Down Expand Up @@ -620,16 +621,18 @@ vips_icc_load_profile_blob(VipsIcc *icc, VipsBlob *blob,
}

icc->selected_intent = icc->intent;
if (!cmsIsIntentSupported(profile, icc->intent, direction)) {
if (icc->intent == VIPS_INTENT_AUTO ||
!cmsIsIntentSupported(profile, icc->intent, direction))
icc->selected_intent = (VipsIntent) cmsGetHeaderRenderingIntent(
profile);

if (icc->intent != VIPS_INTENT_AUTO &&
icc->selected_intent != icc->intent)
g_warning(_("fallback to suggested %s intent, as profile "
"does not support %s %s intent"),
vips_enum_nick(VIPS_TYPE_INTENT, icc->selected_intent),
vips_enum_nick(VIPS_TYPE_INTENT, icc->intent),
direction == LCMS_USED_AS_INPUT ? _("input") : _("output"));
}

#ifdef DEBUG
vips_icc_print_profile("loaded from blob to make", profile);
Expand Down
7 changes: 6 additions & 1 deletion libvips/include/vips/colour.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,18 @@ extern "C" {
#define VIPS_D3250_Y0 (100.0)
#define VIPS_D3250_Z0 (45.8501)

/* Note: constants align with those defined in lcms2.h.
/* Note: constants align with those defined in lcms2.h, except for
* VIPS_INTENT_AUTO, which is libvips-specific.
*/
typedef enum {
VIPS_INTENT_PERCEPTUAL = 0,
VIPS_INTENT_RELATIVE,
VIPS_INTENT_SATURATION,
VIPS_INTENT_ABSOLUTE,
/* Leave room for possible new rendering intents beyond the
* four standard ones.
*/
VIPS_INTENT_AUTO = 32,
VIPS_INTENT_LAST
} VipsIntent;

Expand Down
Loading