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

bug[fetchart]: Only one of the resize operation is executed. #5151

Open
Dr-Blank opened this issue Mar 18, 2024 · 1 comment · May be fixed by #5152
Open

bug[fetchart]: Only one of the resize operation is executed. #5151

Dr-Blank opened this issue Mar 18, 2024 · 1 comment · May be fixed by #5152

Comments

@Dr-Blank
Copy link
Contributor

Consider a case where a coverart is of PNG format with size 15 MB. (happens sometimes with itunes coverart on musicbrainz).

Also consider the following fetchart config:

plugins: fetchart
fetchart:
  sources:
    - filesystem
    - coverart: release
    - itunes
    - amazon
    - albumart
    - coverart: releasegroup
    - "*"
  max_filesize: 3500000
  cover_format: JPEG

PIL is used as the image resizer

Problem

$ beet -vv fetchart
Candidate._validate(self, plugin)
# returns only CANDIDATE_DOWNSIZE
# and skips CANDIDATE_REFORMAT

the function can only perform one of the operations in the current scenario, and since downsizing is returned before reformatting, during .resize() only downsizing takes place. Which is its own separate bug since PIL can not downnsize PNG files.

Setup

  • OS: Windows
  • Python version: 3.11.0b1
  • beets version: b09806e
  • Turning off plugins made problem go away (yes/no): N/A
@Dr-Blank
Copy link
Contributor Author

proposed solution

  1. make validate return a list of operations to perform instead of just one of them with priority:
    CANDIDATE_REFORMAT > CANDIDATE_DOWNSCALE > CANDIDATE_DOWNSIZE
    not sure where CANDIDATE_DEINTERLACE would go
    during .resize() pop each operation from the list and perform.
    Note: however, before resizing a check should be placed since previous operation might have done the size reducing.

  2. option to, recurse until _validate returns CANDIDATE_EXACT with above the above operation priority.
    Note: can get stuck on resizing since PNG cannot be resized, so either validate or the function doing the recursion should move on to next operation of downsizing fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant