mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
parent
debbe4efa5
commit
07eb26f276
3 changed files with 26 additions and 14 deletions
|
|
@ -343,9 +343,10 @@ class ConvertPlugin(BeetsPlugin):
|
||||||
if self.config['embed'] and not linked:
|
if self.config['embed'] and not linked:
|
||||||
album = item._cached_album
|
album = item._cached_album
|
||||||
if album and album.artpath:
|
if album and album.artpath:
|
||||||
|
maxwidth = self._get_art_resize(album.artpath)
|
||||||
self._log.debug('embedding album art from {}',
|
self._log.debug('embedding album art from {}',
|
||||||
util.displayable_path(album.artpath))
|
util.displayable_path(album.artpath))
|
||||||
art.embed_item(self._log, item, album.artpath,
|
art.embed_item(self._log, item, album.artpath, maxwidth,
|
||||||
itempath=converted, id3v23=id3v23)
|
itempath=converted, id3v23=id3v23)
|
||||||
|
|
||||||
if keep_new:
|
if keep_new:
|
||||||
|
|
@ -389,20 +390,10 @@ class ConvertPlugin(BeetsPlugin):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Decide whether we need to resize the cover-art image.
|
# Decide whether we need to resize the cover-art image.
|
||||||
resize = False
|
maxwidth = self._get_art_resize(album.artpath)
|
||||||
maxwidth = None
|
|
||||||
if self.config['album_art_maxwidth']:
|
|
||||||
maxwidth = self.config['album_art_maxwidth'].get(int)
|
|
||||||
size = ArtResizer.shared.get_size(album.artpath)
|
|
||||||
self._log.debug('image size: {}', size)
|
|
||||||
if size:
|
|
||||||
resize = size[0] > maxwidth
|
|
||||||
else:
|
|
||||||
self._log.warning('Could not get size of image (please see '
|
|
||||||
'documentation for dependencies).')
|
|
||||||
|
|
||||||
# Either copy or resize (while copying) the image.
|
# Either copy or resize (while copying) the image.
|
||||||
if resize:
|
if maxwidth is not None:
|
||||||
self._log.info('Resizing cover art from {0} to {1}',
|
self._log.info('Resizing cover art from {0} to {1}',
|
||||||
util.displayable_path(album.artpath),
|
util.displayable_path(album.artpath),
|
||||||
util.displayable_path(dest))
|
util.displayable_path(dest))
|
||||||
|
|
@ -531,6 +522,24 @@ class ConvertPlugin(BeetsPlugin):
|
||||||
)
|
)
|
||||||
util.remove(source_path, False)
|
util.remove(source_path, False)
|
||||||
|
|
||||||
|
def _get_art_resize(self, artpath):
|
||||||
|
"""For a given piece of album art, determine whether or not it needs
|
||||||
|
to be resized according to the user's settings. If so, returns the
|
||||||
|
new size. If not, returns None.
|
||||||
|
"""
|
||||||
|
newwidth = None
|
||||||
|
if self.config['album_art_maxwidth']:
|
||||||
|
maxwidth = self.config['album_art_maxwidth'].get(int)
|
||||||
|
size = ArtResizer.shared.get_size(artpath)
|
||||||
|
self._log.debug('image size: {}', size)
|
||||||
|
if size:
|
||||||
|
if size[0] > maxwidth:
|
||||||
|
newwidth = maxwidth
|
||||||
|
else:
|
||||||
|
self._log.warning('Could not get size of image (please see '
|
||||||
|
'documentation for dependencies).')
|
||||||
|
return newwidth
|
||||||
|
|
||||||
def _cleanup(self, task, session):
|
def _cleanup(self, task, session):
|
||||||
for path in task.old_paths:
|
for path in task.old_paths:
|
||||||
if path in _temp_files:
|
if path in _temp_files:
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ New features:
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
||||||
|
* :doc:`/plugins/convert`: Resize album art when embedding
|
||||||
|
:bug:`2116`
|
||||||
* :doc:`/plugins/deezer`: Fix auto tagger pagination issues (fetch beyond the
|
* :doc:`/plugins/deezer`: Fix auto tagger pagination issues (fetch beyond the
|
||||||
first 25 tracks of a release).
|
first 25 tracks of a release).
|
||||||
* :doc:`/plugins/spotify`: Fix auto tagger pagination issues (fetch beyond the
|
* :doc:`/plugins/spotify`: Fix auto tagger pagination issues (fetch beyond the
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,8 @@ file. The available options are:
|
||||||
using the ``-a`` option. Default: ``no``.
|
using the ``-a`` option. Default: ``no``.
|
||||||
- **album_art_maxwidth**: Downscale album art if it's too big. The resize
|
- **album_art_maxwidth**: Downscale album art if it's too big. The resize
|
||||||
operation reduces image width to at most ``maxwidth`` pixels while
|
operation reduces image width to at most ``maxwidth`` pixels while
|
||||||
preserving the aspect ratio.
|
preserving the aspect ratio. The specified image size will apply to both
|
||||||
|
embedded album art and external image files.
|
||||||
- **dest**: The directory where the files will be converted (or copied) to.
|
- **dest**: The directory where the files will be converted (or copied) to.
|
||||||
Default: none.
|
Default: none.
|
||||||
- **embed**: Embed album art in converted items. Default: ``yes``.
|
- **embed**: Embed album art in converted items. Default: ``yes``.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue