diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index 2be0ed9c0b..badac9d794 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -409,7 +409,16 @@ def _is_valid_image_candidate(self, candidate): if not (self.enforce_ratio or self.minwidth): return True + # get_size returns None if no local imaging backend is available size = ArtResizer.shared.get_size(candidate) + + if not size: + self._log.warning(u'could not verify size of image: please see ' + u'documentation for dependencies. ' + u'The configuration options `minwidth` and ' + u'`enforce_ratio` may be violated.') + return True + return size and size[0] >= self.minwidth and \ (not self.enforce_ratio or size[0] == size[1]) @@ -446,6 +455,7 @@ def art_for_album(self, album, paths, local_only=False): if self.maxwidth and out: out = ArtResizer.shared.resize(self.maxwidth, out) + return out def batch_fetch_art(self, lib, albums, force): diff --git a/docs/changelog.rst b/docs/changelog.rst index 72eb157a0e..eb80cddbc2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -11,6 +11,8 @@ New features: or alternatively any list of attributes that should be favored. * The :doc:`/plugins/metasync` plugin now lets you get metadata from iTunes. This plugin is still in an experimental phase. :bug:`1450` +* The :doc:`/plugins/fetchart` plugin will now complain for the `enforce_ratio` + and `min_width` options if no local imaging backend is available. :bug:`1460` Fixes: diff --git a/docs/plugins/fetchart.rst b/docs/plugins/fetchart.rst index 81f4be6aa7..fef0d7f9e1 100644 --- a/docs/plugins/fetchart.rst +++ b/docs/plugins/fetchart.rst @@ -54,6 +54,12 @@ file. The available options are: Default: ``coverart itunes albumart amazon google wikipedia``, i.e., all sources. +Note: ``minwidth`` and ``enforce_ratio`` options require either `ImageMagick`_ +or `PIL`_. + +.. _PIL: http://www.pythonware.com/products/pil/ +.. _ImageMagick: http://www.imagemagick.org/ + Here's an example that makes plugin select only images that contain *front* or *back* keywords in their filenames and prioritizes the iTunes source over others:: diff --git a/test/test_art.py b/test/test_art.py index 9825a4bc7a..6fe62fc84e 100644 --- a/test/test_art.py +++ b/test/test_art.py @@ -30,11 +30,15 @@ from beets import importer from beets import config from beets import logging +from beets.util.artresizer import ArtResizer, WEBPROXY logger = logging.getLogger('beets.test_art') +ARTRESIZER_USES_FALLBACK_BACKEND = ArtResizer.shared.method[0] == WEBPROXY + + class UseThePlugin(_common.TestCase): def setUp(self): super(UseThePlugin, self).setUp() @@ -408,11 +412,15 @@ def _assertImageIsValidArt(self, image_file, should_exist): else: self.assertIsNone(local_artpath) + @unittest.skipIf(ARTRESIZER_USES_FALLBACK_BACKEND, + 'ArtResizer has no local imaging backend available') def test_respect_minwidth(self): self.plugin.minwidth = 300 self._assertImageIsValidArt(self.IMG_225x225, False) self._assertImageIsValidArt(self.IMG_348x348, True) + @unittest.skipIf(ARTRESIZER_USES_FALLBACK_BACKEND, + 'ArtResizer has no local imaging backend available') def test_respect_enforce_ratio_yes(self): self.plugin.enforce_ratio = True self._assertImageIsValidArt(self.IMG_500x490, False)