mirror of
https://github.com/photoprism/photoprism.git
synced 2026-01-22 18:18:39 +00:00
Vips: Only call GetString() if interop index exists #5389
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
82c5989b30
commit
69acd58e12
2 changed files with 16 additions and 1 deletions
|
|
@ -79,6 +79,7 @@ func Vips(imageName string, imageBuffer []byte, hash, thumbPath string, width, h
|
|||
// Use defaults.
|
||||
}
|
||||
|
||||
// Embed an ICC profile when a JPEG declares its color space via the EXIF InteroperabilityIndex tag.
|
||||
if err = vipsSetIccProfileForInteropIndex(img, clean.Log(filepath.Base(imageName))); err != nil {
|
||||
log.Debugf("vips: %s in %s (set icc profile for interop index tag)", err, clean.Log(filepath.Base(imageName)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,21 @@ func vipsSetIccProfileForInteropIndex(img *vips.ImageRef, logName string) (err e
|
|||
// Some cameras signal color space via EXIF InteroperabilityIndex instead of
|
||||
// embedding an ICC profile. Browsers and libvips ignore this tag, so we
|
||||
// inject a matching ICC profile to produce correct thumbnails.
|
||||
iiFull := img.GetString("exif-ifd4-InteroperabilityIndex")
|
||||
iiField := "exif-ifd4-InteroperabilityIndex"
|
||||
hasInterop := false
|
||||
|
||||
for _, field := range img.GetFields() {
|
||||
if field == iiField {
|
||||
hasInterop = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !hasInterop {
|
||||
return nil
|
||||
}
|
||||
|
||||
iiFull := img.GetString(iiField)
|
||||
|
||||
if iiFull == "" {
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue