File: imagecms_flags.patch

package info (click to toggle)
thumbor 7.7.7-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 40,556 kB
  • sloc: xml: 295,435; python: 18,673; ansic: 1,479; makefile: 360; sh: 27
file content (32 lines) | stat: -rw-r--r-- 1,024 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Description: Maintain compatibility with multiple Pillow versions in ImageCms
Author: Marcelo Jorge Vieira <metal@debian.org>
Forwarded: https://github.com/thumbor/thumbor/pull/1788
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/thumbor/utils.py
+++ b/thumbor/utils.py
@@ -22,11 +22,20 @@
     DEFAULT_SRGB_PROFILE = ImageCms.ImageCmsProfile(
         ImageCms.createProfile("sRGB")
     )
+
+    def _get_flag(flags, name):
+        try:
+            return flags[name]
+        except Exception:
+            return getattr(flags, name, 0)
+
+    _FLAGS = getattr(ImageCms, "FLAGS", ImageCms.Flags)
+
     TRANSFORM_FLAGS = (
-        ImageCms.FLAGS["NOTCACHE"]
-        | ImageCms.FLAGS["NOTPRECALC"]
-        | ImageCms.FLAGS["BLACKPOINTCOMPENSATION"]
-        | ImageCms.FLAGS["HIGHRESPRECALC"]
+        _get_flag(_FLAGS, "NOTCACHE")
+        | _get_flag(_FLAGS, "NOTPRECALC")
+        | _get_flag(_FLAGS, "BLACKPOINTCOMPENSATION")
+        | _get_flag(_FLAGS, "HIGHRESPRECALC")
     )