[Python-modules-commits] [willow] 05/11: Added has_alpha and has_animation operations
Christopher Stuart Hoskin
mans0954 at moszumanska.debian.org
Tue Dec 5 23:12:18 UTC 2017
This is an automated email from the git hooks/post-receive script.
mans0954 pushed a commit to tag v0.1.1
in repository willow.
commit ad778c713d7694585737871055e61984f9a55a20
Author: Karl Hobley <karlhobley10 at gmail.com>
Date: Wed Feb 18 16:24:57 2015 +0000
Added has_alpha and has_animation operations
---
willow/backends/pillow.py | 12 ++++++++++++
willow/backends/wand.py | 10 ++++++++++
2 files changed, 22 insertions(+)
diff --git a/willow/backends/pillow.py b/willow/backends/pillow.py
index fbe58ac..be34411 100644
--- a/willow/backends/pillow.py
+++ b/willow/backends/pillow.py
@@ -71,3 +71,15 @@ def pillow_save_as_jpeg(backend, f, quality=85):
@PillowBackend.register_operation('save_as_png')
def pillow_save_as_png(backend, f):
backend.image.save(f, 'PNG')
+
+
+ at PillowBackend.register_operation('has_alpha')
+def pillow_has_alpha(backend):
+ img = backend.image
+ return img.mode in ('RGBA', 'LA') or (img.mode == 'P' and 'transparency' in img.info)
+
+
+ at PillowBackend.register_operation('has_animation')
+def pillow_has_animation(backend):
+ # Animation not supported by PIL
+ return False
diff --git a/willow/backends/wand.py b/willow/backends/wand.py
index d2f3b2a..0c29721 100644
--- a/willow/backends/wand.py
+++ b/willow/backends/wand.py
@@ -54,3 +54,13 @@ def wand_resize(backend, width, height):
@WandBackend.register_operation('crop')
def wand_crop(backend, left, top, right, bottom):
backend.image.crop(left=left, top=top, right=right, bottom=bottom)
+
+
+ at WandBackend.register_operation('has_alpha')
+def wand_has_alpha(backend):
+ return backend.image.alpha_channel
+
+
+ at WandBackend.register_operation('has_animation')
+def wand_has_animation(backend):
+ return backend.image.animation
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/willow.git
More information about the Python-modules-commits
mailing list