Explorar el Código

conserve ICC profiles of scaled images, to make colors look right-er

allanman hace 9 años
padre
commit
87b3554969
Se han modificado 1 ficheros con 5 adiciones y 4 borrados
  1. 5 4
      photos/photos.py

+ 5 - 4
photos/photos.py

@@ -65,8 +65,9 @@ def resize_photos(generator, writer):
                 os.path.getmtime(orig) > os.path.getmtime(resized)):
             logger.info('photos: make photo %s -> %s', orig, resized)
             im = Image.open(orig)
-            try:
+	    try:
                 exif = im._getexif()
+                icc_profile = im.info.get("icc_profile")
             except Exception:
                 exif = None
             if exif:
@@ -82,8 +83,8 @@ 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)
+        print(resized)
 
 def detect_content(content):
 
@@ -105,7 +106,7 @@ def detect_content(content):
                     path,
                     os.path.join('photos', photo),
                     settings['PHOTO_ARTICLE'])
-
+                print(origin)
         return ''.join((m.group('markup'), m.group('quote'), origin,
                         m.group('quote')))