Skip to content

Commit

Permalink
artresizer: parse output of identify command to check IM version
Browse files Browse the repository at this point in the history
we used to parse `convert` output but `convert` happens to be a
Windows cli command too. using `identify` is less error prone.
  • Loading branch information
Kraymer committed Sep 22, 2014
1 parent e4180e4 commit a0c38a0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion beets/util/artresizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,15 @@ def local(self):

def _can_compare(self):
"""A boolean indicating whether image comparison is available"""

return self.method[0] == IMAGEMAGICK and self.method[1] > (6, 8, 7)

@staticmethod
def _check_method(method=None):
"""A tuple indicating whether current method is available and its version.
If no method is given, it returns a supported one.
"""

# Guess available method
if not method:
for m in [IMAGEMAGICK, PIL]:
Expand All @@ -183,9 +185,11 @@ def _check_method(method=None):
return (WEBPROXY, (0))

if method == IMAGEMAGICK:

# Try invoking ImageMagick's "convert".
try:
out = util.command_output(['convert', '--version'])
out = util.command_output(['identify', '--version'])

if 'imagemagick' in out.lower():
pattern = r".+ (\d+)\.(\d+)\.(\d+).*"
match = re.search(pattern, out)
Expand Down

0 comments on commit a0c38a0

Please sign in to comment.