Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image similarity comparison should use modern magick binary when available #4272

Closed
ITguy3118 opened this issue Feb 6, 2022 · 4 comments · Fixed by #4275
Closed

Image similarity comparison should use modern magick binary when available #4272

ITguy3118 opened this issue Feb 6, 2022 · 4 comments · Fixed by #4275
Labels
feature features we would like to implement

Comments

@ITguy3118
Copy link

ITguy3118 commented Feb 6, 2022

Beets is having intermittent issues with the latest version of Imagemagick as it seems the commands used to call compare,convert, etc have changed in the latest verison IM 7. in a cmd prompt running 'Magick compare' produces output as pictured below. 'Magick' was not required in previous versions.

2022-05-02-23_28_50-VMHost - VMHost - Remote Desktop Connection

lyrics: fetched lyrics: Prince - 3121 - 3121
Sending event: art_set
embedart: Embedding album art into Otep - KULT 45
Sending event: database_change
embedart: Extracting album art from: Otep - KULT 45 - Hail to the Thief to: C:\Users\ANDREW~1\AppData\Local\Temp\tmpj8j8woil.jpg
embedart: comparing images with pipeline ['convert', 'F:\\Download Queues\\Complete\\Music Library Temp\\Artists\\Otep\\2018 - KULT 45\\thumb.jpg', 'C:\\Users\\ANDREW~1\\AppData\\Local\\Temp\\tmpj8j8woil.jpg', '-colorspace', 'gray', 'MIFF:-'] | ['compare', '-metric', 'PHASH', '-', 'null:']
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Prince/Lolita (404)
lyrics: Received unusual song page html
lyrics: got lyrics from backend: Genius
lyrics: fetched lyrics: Prince - 3121 - Lolita
Sending event: database_change
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Prince/Te-Amo-Coraz%C3%B3n (404)
lyrics: Received unusual song page html
lyrics: got lyrics from backend: Genius
lyrics: fetched lyrics: Prince - 3121 - Te Amo Corazón
Sending event: database_change
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Prince/Black-Sweat (404)
lyrics: Received unusual song page html
lyrics: got lyrics from backend: Genius
lyrics: fetched lyrics: Prince - 3121 - Black Sweat
Sending event: database_change
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Prince/Incense-And-Candles (404)
lyrics: Received unusual song page html
lyrics: got lyrics from backend: Genius
lyrics: fetched lyrics: Prince - 3121 - Incense and Candles
Sending event: database_change
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Prince/Love (404)
lyrics: Received unusual song page html
lyrics: got lyrics from backend: Genius
lyrics: fetched lyrics: Prince - 3121 - Love
Sending event: database_change
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Prince/Satisfied (404)
lyrics: Received unusual song page html
lyrics: got lyrics from backend: Genius
lyrics: fetched lyrics: Prince - 3121 - Satisfied
Sending event: database_change
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Prince/Fury (404)
lyrics: Received unusual song page html
lyrics: got lyrics from backend: Genius
lyrics: fetched lyrics: Prince - 3121 - Fury
Sending event: database_change
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Prince/The-Word (404)
lyrics: Received unusual song page html
lyrics: got lyrics from backend: Genius
lyrics: fetched lyrics: Prince - 3121 - The Word
Sending event: database_change
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Prince/Beautiful%2C-Loved-And-Blessed (404)lyrics: Received unusual song page html
lyrics: got lyrics from backend: Genius
lyrics: fetched lyrics: Prince - 3121 - Beautiful, Loved and Blessed
Sending event: database_change
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Prince/The-Dance (404)
lyrics: Received unusual song page html
lyrics: got lyrics from backend: Genius
lyrics: fetched lyrics: Prince - 3121 - The Dance
Sending event: database_change
lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Prince/Get-On-The-Boat (404)
lyrics: Received unusual song page html
lyrics: got lyrics from backend: Genius
lyrics: fetched lyrics: Prince - 3121 - Get on the Boat
Sending event: database_change
Traceback (most recent call last):
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\Scripts\beet-script.py", line 33, in <module>
    sys.exit(load_entry_point('beets==1.6.1', 'console_scripts', 'beet')())
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\ui\__init__.py", line 1285, in main
    _raw_main(args)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\ui\__init__.py", line 1272, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\ui\commands.py", line 973, in import_func
    import_files(lib, paths, query)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\ui\commands.py", line 943, in import_files
    session.run()
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\importer.py", line 340, in run
    pl.run_parallel(QUEUE_SIZE)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\util\pipeline.py", line 446, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\util\pipeline.py", line 358, in run
    self.coro.send(msg)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\util\pipeline.py", line 170, in coro
    task = func(*(args + (task,)))
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\importer.py", line 1566, in manipulate_files
    task.manipulate_files(
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\importer.py", line 766, in manipulate_files
    plugins.send('import_task_files', session=session, task=self)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\plugins.py", line 488, in send
    result = handler(**arguments)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\plugins.py", line 145, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beetsplug\fetchart.py", line 1063, in assign_art
    self._set_art(task.album, candidate, not self.src_removed)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beetsplug\fetchart.py", line 1048, in _set_art
    album.set_art(candidate.path, delete)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\library.py", line 1340, in set_art
    plugins.send('art_set', album=self)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\plugins.py", line 488, in send
    result = handler(**arguments)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\plugins.py", line 145, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beetsplug\embedart.py", line 187, in process_album
    art.embed_album(self._log, album, max_width, True,
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\art.py", line 103, in embed_album
    embed_item(log, item, imagepath, maxwidth, None, compare_threshold,
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\art.py", line 58, in embed_item
    if not check_art_similarity(log, item, imagepath, compare_threshold):
  File "C:\Users\Andrew Sutcliffe\AppData\Roaming\Python\Python310\site-packages\beets\art.py", line 144, in check_art_similarity
    compare_proc = subprocess.Popen(
  File "C:\Program Files\Python310\lib\subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Program Files\Python310\lib\subprocess.py", line 1435, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
@sampsyo sampsyo added the needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." label Feb 6, 2022
@sampsyo
Copy link
Member

sampsyo commented Feb 6, 2022

Interesting! The ImageMagick wrapper is supposed to automatically detects whether to use the convert binary or the magick convert subcommand here:

for cmd_name, legacy in ((['magick'], False), (['convert'], True)):

It's a little hard too see what's going on from that output (it might be a bit easier if you used a fenced code block in the Markdown for the comment, i.e., wrapped the output in ``` markers?). I suppose we should be logging a bit more information to show the result of the get_im_version version check, and to show what command we're actually trying to execute… that could help narrow down what's crashing.

@jackwilsdon
Copy link
Member

jackwilsdon commented Feb 6, 2022

@sampsyo - it doesn't look like we actually use our ImageMagick wrapper for checking art similarity:

beets/beets/art.py

Lines 135 to 143 in debbe4e

compare_cmd = ['compare', '-metric', 'PHASH', '-', 'null:']
log.debug('comparing images with pipeline {} | {}',
convert_cmd, compare_cmd)
convert_proc = subprocess.Popen(
convert_cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=not is_windows,
)

I guess the fix is to start using it.

@ITguy3118
Copy link
Author

apologies, fixed the code post

@sampsyo
Copy link
Member

sampsyo commented Feb 6, 2022

Aha, thanks, @jackwilsdon! Yes indeed. It would be great if we could share some code to centralize the IM command detection…

@sampsyo sampsyo changed the title Beets command mismatch with Imagemagick Image similarity comparison should use modern magick binary when available Feb 6, 2022
@sampsyo sampsyo added feature features we would like to implement and removed needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." labels Feb 6, 2022
wisp3rwind added a commit to wisp3rwind/beets that referenced this issue Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature features we would like to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants