Skip to content

Commit 79a5afd

Browse files
committed
Vips: Skip all images that already have an ICC profile photoprism#5389
Signed-off-by: Michael Mayer <michael@photoprism.app>
1 parent 69acd58 commit 79a5afd

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

internal/thumb/vips_icc.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const (
2727
// but lacks an embedded profile. If an ICC profile is already present, it
2828
// leaves the image untouched.
2929
func vipsSetIccProfileForInteropIndex(img *vips.ImageRef, logName string) (err error) {
30+
if img.HasICCProfile() {
31+
return nil
32+
}
33+
3034
// Some cameras signal color space via EXIF InteroperabilityIndex instead of
3135
// embedding an ICC profile. Browsers and libvips ignore this tag, so we
3236
// inject a matching ICC profile to produce correct thumbnails.
@@ -54,34 +58,29 @@ func vipsSetIccProfileForInteropIndex(img *vips.ImageRef, logName string) (err e
5458
// a string with a trailing space. Using the first three bytes covers the
5559
// meaningful code (e.g., "R03", "R98").
5660
if len(iiFull) < 3 {
57-
log.Debugf("interopindex: %s has unexpected interop index %q", logName, iiFull)
61+
log.Debugf("vips: %s has unexpected interop index %q", logName, iiFull)
5862
return nil
5963
}
6064

6165
ii := iiFull[:3]
62-
log.Tracef("interopindex: %s read exif and got interopindex %s, %s", logName, ii, iiFull)
63-
64-
if img.HasICCProfile() {
65-
log.Debugf("interopindex: %s already has an embedded ICC profile; skipping fallback.", logName)
66-
return nil
67-
}
66+
log.Tracef("vips: %s read exif and got interopindex %s, %s", logName, ii, iiFull)
6867

69-
profilePath := ""
68+
var profilePath string
7069

7170
switch ii {
7271
case InteropIndexAdobeRGB:
7372
// Use Adobe RGB 1998 compatible profile.
7473
profilePath, err = GetIccProfile(IccAdobeRGBCompat, IccAdobeRGBCompatV2, IccAdobeRGBCompatV4)
7574

7675
if err != nil {
77-
return fmt.Errorf("interopindex %s: %w", ii, err)
76+
return fmt.Errorf("vips: failed to get %s profile for %s (%w)", ii, logName, err)
7877
}
7978
case InteropIndexSRGB:
8079
// sRGB: browsers and libvips assume sRGB by default, so no embed needed.
8180
case InteropIndexThumb:
8281
// Thumbnail file; specification unclear—treat as sRGB and do nothing.
8382
default:
84-
log.Debugf("interopindex: %s has unknown interop index %s", logName, ii)
83+
log.Debugf("vips: %s has unknown interop index %s", logName, ii)
8584
}
8685

8786
if profilePath == "" {

0 commit comments

Comments
 (0)