sampsyo/beets — pull request #974 by KraYmer (2014-09-21 12:41:14+00:00)
Title: embedart: write candidate image only if it is "similar" to already embedded one (suite)

Original issue : #848
Continuation of work started by PR #966

Taken from the docs :

> The ``compare_threshold`` option defines how similar must candidate art be regarding to embedded art to be written to the file.
> This works by computing the perceptual hashes (`PHASH`_) of the two images and checking that the difference between the two does not exceed a given threshold.
> The threshold used is given by the ``compare_threshold`` option:
> * use '0' to always embed image (disable similarity check)
> * use any positive integer to define a similarity threshold. The smaller the value, the more similar the images must be. A value in the range [10,100] is recommended.

Additional commit infos :

- `26ec2b8`: I kinda hacked ArtResizer original goal, using it only to inform me if IM is installed or not. In the long term we might want to do some other basics operations and renaming the class into ArtProcessor or something would fit better I think.
- `a06c27` : what's tricky here is that `compare` return code is `1` in case of non match, yet the two images in such case may be judged as similar from a human point of view. So I needed to interpret the printed diff value even when `CalledProcessError` is raised. Maybe this edit to `command_output` could be done more elegantly ?
- `187497c`: I don't know what range of values can `compare -metric PHASH` return ([0, ?]), so I decided to let user set the threshold and hinting at a reasonable max in the docs (100)