aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-11-19 04:23:24 +0100
committerMattias Andrée <maandree@operamail.com>2015-11-19 04:23:24 +0100
commit8cae9fc6b9ebe348ed49c7967e5d33cd1ea89a31 (patch)
treedfbcf6f3b6b8c8b587f4ae66af943d181f4eec61 /src
parentm (diff)
downloadxpybar-8cae9fc6b9ebe348ed49c7967e5d33cd1ea89a31.tar.gz
xpybar-8cae9fc6b9ebe348ed49c7967e5d33cd1ea89a31.tar.bz2
xpybar-8cae9fc6b9ebe348ed49c7967e5d33cd1ea89a31.tar.xz
work around regression bug in ImageMagick and deficiency in GaphicsMagick1.12
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/plugins/image.py34
1 files changed, 12 insertions, 22 deletions
diff --git a/src/plugins/image.py b/src/plugins/image.py
index 5653ed7..97ad7c0 100644
--- a/src/plugins/image.py
+++ b/src/plugins/image.py
@@ -71,20 +71,25 @@ class Image:
if not convert.wait() == 0:
raise Exception('Image could not be converted')
- convert = ['gm'] if Image.have_graphicsmagick() else []
- convert += ['convert', '-', '-background', background, '-alpha', 'remove', '-depth', '8']
- if width is not None:
- convert += ['-resize', '%ix%i!' % (width, height)]
- convert += ['ppm:-']
+ convert = ['convert', '-', '-background', background, '-alpha', 'remove', '-depth', '8', 'ppm:-']
convert = Popen(convert, stdin = PIPE if raster is not None else open(file, 'rb'),
stdout = PIPE, stderr = sys.stderr)
if raster is not None:
- self.data = list(convert.communicate(raster)[0])
+ self.data = convert.communicate(raster)[0]
else:
- self.data = list(convert.communicate()[0])
+ self.data = convert.communicate()[0]
if not convert.wait() == 0:
raise Exception('Image could not be converted')
+ if width is not None:
+ convert = ['gm', 'convert', '-', '-resize', '%ix%i!' % (width, height), 'ppm:-']
+ convert = Popen(convert, stdin = PIPE, stdout = PIPE, stderr = sys.stderr)
+ self.data = convert.communicate(self.data)[0]
+ if not convert.wait() == 0:
+ raise Exception('Image could not be resized')
+
+ self.data = list(self.data)
+
self.width, self.height, state, comment = [], [], 0, False
for i in range(len(self.data)):
b = self.data[i]
@@ -132,21 +137,6 @@ class Image:
@staticmethod
- def have_graphicsmagick():
- '''
- Figure out whether graphicsmagick is installed
-
- @return :bool Whether graphicsmagick is installed
- '''
- import os
- path = os.environ['PATH'] if 'PATH' in os.environ else '/usr/local/bin:/usr/bin:/bin';
- for p in [p + '/gm' for p in path.split(':') if not p == '']:
- if os.access(p, os.X_OK):
- return True
- return False
-
-
- @staticmethod
def find_icon(name, width, height, preferences):
'''
Find and image for in abstract icon