Selaa lähdekoodia

Merge pull request #541 from allanman/photos-icc

Photos plugin: conserve ICC profiles for more correct colors after scaling/thumbnailing
Justin Mayer 9 vuotta sitten
vanhempi
commit
b5bb5fcb81
1 muutettua tiedostoa jossa 5 lisäystä ja 3 poistoa
  1. 5 3
      photos/photos.py

+ 5 - 3
photos/photos.py

@@ -69,6 +69,10 @@ def resize_photos(generator, writer):
                 exif = im._getexif()
             except Exception:
                 exif = None
+            try:
+                icc_profile = im.info.get("icc_profile")
+            except Exception:
+                icc_profile = None
             if exif:
                 for tag, value in exif.items():
                     decoded = ExifTags.TAGS.get(tag, tag)
@@ -82,8 +86,7 @@ def resize_photos(generator, writer):
                 os.makedirs(os.path.split(resized)[0])
             except:
                 pass
-            im.save(resized, 'JPEG', quality=spec[2])
-
+            im.save(resized, 'JPEG', quality=spec[2], icc_profile=icc_profile)
 
 def detect_content(content):
 
@@ -105,7 +108,6 @@ def detect_content(content):
                     path,
                     os.path.join('photos', photo),
                     settings['PHOTO_ARTICLE'])
-
         return ''.join((m.group('markup'), m.group('quote'), origin,
                         m.group('quote')))