| 1 |
EmbedArt Plugin |
| 2 |
=============== |
| 3 |
|
| 4 |
Typically, beets stores album art in a "file on the side": along with each |
| 5 |
album, there is a file (named "cover.jpg" by default) that stores the album art. |
| 6 |
You might want to embed the album art directly into each file's metadata. While |
| 7 |
this will take more space than the external-file approach, it is necessary for |
| 8 |
displaying album art in some media players (iPods, for example). |
| 9 |
|
| 10 |
Embedding Art Automatically |
| 11 |
--------------------------- |
| 12 |
|
| 13 |
To use the ``embedart`` plugin, first enable it in your configuration (see |
| 14 |
:ref:`using-plugins`). Then, install ``beets`` with ``embedart`` extra |
| 15 |
|
| 16 |
.. code-block:: bash |
| 17 |
|
| 18 |
pip install "beets[embedart]" |
| 19 |
|
| 20 |
You'll also want to enable the :doc:`/plugins/fetchart` to obtain the images to |
| 21 |
be embedded. Art will be embedded after each album has its cover art set. |
| 22 |
|
| 23 |
This behavior can be disabled with the ``auto`` config option (see below). |
| 24 |
|
| 25 |
.. _image-similarity-check: |
| 26 |
|
| 27 |
Image Similarity |
| 28 |
~~~~~~~~~~~~~~~~ |
| 29 |
|
| 30 |
When importing a lot of files with the ``auto`` option, one may be reluctant to |
| 31 |
overwrite existing embedded art for all of them. |
| 32 |
|
| 33 |
You can tell beets to avoid embedding images that are too different from the |
| 34 |
existing ones. This works by computing the perceptual hashes (PHASH_) of the two |
| 35 |
images and checking that the difference between the two does not exceed a |
| 36 |
threshold. You can set the threshold with the ``compare_threshold`` option. |
| 37 |
|
| 38 |
A threshold of 0 (the default) disables similarity checking and always embeds |
| 39 |
new images. Set the threshold to another number---we recommend between 10 and |
| 40 |
100---to adjust the sensitivity of the comparison. The smaller the threshold |
| 41 |
number, the more similar the images must be. |
| 42 |
|
| 43 |
This feature requires ImageMagick_. |
| 44 |
|
| 45 |
Configuration |
| 46 |
------------- |
| 47 |
|
| 48 |
To configure the plugin, make an ``embedart:`` section in your configuration |
| 49 |
file. The available options are: |
| 50 |
|
| 51 |
- **auto**: Enable automatic album art embedding. Default: ``yes``. |
| 52 |
- **compare_threshold**: How similar candidate art must be to existing art to be |
| 53 |
written to the file (see :ref:`image-similarity-check`). Default: 0 |
| 54 |
(disabled). |
| 55 |
- **ifempty**: Avoid embedding album art for files that already have art |
| 56 |
embedded. Default: ``no``. |
| 57 |
- **maxwidth**: A maximum width to downscale images before embedding them (the |
| 58 |
original image file is not altered). The resize operation reduces image width |
| 59 |
to at most ``maxwidth`` pixels. The height is recomputed so that the aspect |
| 60 |
ratio is preserved. See also :ref:`image-resizing` for further caveats about |
| 61 |
image resizing. Default: 0 (disabled). |
| 62 |
- **quality**: The JPEG quality level to use when compressing images (when |
| 63 |
``maxwidth`` is set). This should be either a number from 1 to 100 or 0 to use |
| 64 |
the default quality. 65–75 is usually a good starting point. The default |
| 65 |
behavior depends on the imaging tool used for scaling: ImageMagick tries to |
| 66 |
estimate the input image quality and uses 92 if it cannot be determined, and |
| 67 |
PIL defaults to 75. Default: 0 (disabled) |
| 68 |
- **remove_art_file**: Automatically remove the album art file for the album |
| 69 |
after it has been embedded. This option is best used alongside the |
| 70 |
:doc:`FetchArt </plugins/fetchart>` plugin to download art with the purpose of |
| 71 |
directly embedding it into the file's metadata without an "intermediate" album |
| 72 |
art file. Default: ``no``. |
| 73 |
- **clearart_on_import**: Enable automatic embedded art clearing. Default: |
| 74 |
``no``. |
| 75 |
|
| 76 |
Note: ``compare_threshold`` option requires ImageMagick_, and ``maxwidth`` |
| 77 |
requires either ImageMagick_ or Pillow_. |
| 78 |
|
| 79 |
.. _imagemagick: https://imagemagick.org/ |
| 80 |
|
| 81 |
.. _phash: https://web.archive.org/web/*/http://www.fmwconcepts.com/misc_tests/perceptual_hash_test_results_510/index.html |
| 82 |
|
| 83 |
.. _pillow: https://github.com/python-pillow/Pillow |
| 84 |
|
| 85 |
Manually Embedding and Extracting Art |
| 86 |
------------------------------------- |
| 87 |
|
| 88 |
The ``embedart`` plugin provides a couple of commands for manually managing |
| 89 |
embedded album art: |
| 90 |
|
| 91 |
- ``beet embedart [-f IMAGE] QUERY``: embed images in every track of the albums |
| 92 |
matching the query. If the ``-f`` (``--file``) option is given, then use a |
| 93 |
specific image file from the filesystem; otherwise, each album embeds its own |
| 94 |
currently associated album art. The command prompts for confirmation before |
| 95 |
making the change unless you specify the ``-y`` (``--yes``) option. |
| 96 |
- ``beet embedart [-u IMAGE_URL] QUERY``: embed image specified in the URL into |
| 97 |
every track of the albums matching the query. The ``-u`` (``--url``) option |
| 98 |
can be used to specify the URL of the image to be used. The command prompts |
| 99 |
for confirmation before making the change unless you specify the ``-y`` |
| 100 |
(``--yes``) option. |
| 101 |
- ``beet extractart [-a] [-n FILE] QUERY``: extracts the images for all albums |
| 102 |
matching the query. The images are placed inside the album folder. You can |
| 103 |
specify the destination file name using the ``-n`` option, but leave off the |
| 104 |
extension: it will be chosen automatically. The destination filename is |
| 105 |
specified using the ``art_filename`` configuration option. It defaults to |
| 106 |
``cover`` if it's not specified via ``-o`` nor the config. Using ``-a``, the |
| 107 |
extracted image files are automatically associated with the corresponding |
| 108 |
album. |
| 109 |
- ``beet extractart -o FILE QUERY``: extracts the image from an item matching |
| 110 |
the query and stores it in a file. You have to specify the destination file |
| 111 |
using the ``-o`` option, but leave off the extension: it will be chosen |
| 112 |
automatically. |
| 113 |
- ``beet clearart QUERY``: removes all embedded images from all items matching |
| 114 |
the query. The command prompts for confirmation before making the change |
| 115 |
unless you specify the ``-y`` (``--yes``) option. The files listed for |
| 116 |
confirmation are the ones matching the query independently of having an |
| 117 |
embedded art. However, only the files with an embedded art are updated, |
| 118 |
leaving untouched the files without. |