diff --git a/beets/art.py b/beets/art.py index 7a65a2b80..06b4f8455 100644 --- a/beets/art.py +++ b/beets/art.py @@ -124,15 +124,23 @@ def check_art_similarity(log, item, imagepath, compare_threshold): is_windows = platform.system() == "Windows" # Converting images to grayscale tends to minimize the weight - # of colors in the diff score. + # of colors in the diff score. So we first convert both images + # to grayscale and then pipe them into the `compare` command. + # On Windows, ImageMagick doesn't support the magic \\?\ prefix + # on paths, so we pass `prefix=False` to `syspath`. + convert_cmd = [b'convert', syspath(imagepath, prefix=False), + syspath(art, prefix=False), + b'-colorspace', b'gray', b'MIFF:-'] + compare_cmd = [b'compare', b'-metric', b'PHASH', b'-', b'null:'] + log.debug(u'comparing images with pipeline {} | {}', + convert_cmd, compare_cmd) convert_proc = subprocess.Popen( - [b'convert', syspath(imagepath), syspath(art), - b'-colorspace', b'gray', b'MIFF:-'], + convert_cmd, stdout=subprocess.PIPE, close_fds=not is_windows, ) compare_proc = subprocess.Popen( - [b'compare', b'-metric', b'PHASH', b'-', b'null:'], + compare_cmd, stdin=convert_proc.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE, diff --git a/docs/changelog.rst b/docs/changelog.rst index a6bdb064c..0199d7c54 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,8 @@ Some fixes for Windows: * Queries are now detected as paths when they contain backslashes (in addition to forward slashes). This only applies on Windows. +* :doc:`/plugins/embedart`: Image similarity comparison with ImageMagick + should now work on Windows. Fixes: