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

fix: Correctly resize and save small artwork #1238

Merged
merged 1 commit into from
Oct 12, 2024

Conversation

adamantike
Copy link
Collaborator

The previous implementation was calling resize_cover_to_small within the context manager that was writing the image to the filesystem. This was causing PIL to raise an error because it could not identify the open and temporarily created file as a valid image.

Instead of saving the original image to the filesystem and then resizing it, we now open the image in memory, resize it, and then save it to the filesystem. We also avoid reading the BytesIO object twice by saving small and big images from the same initial Image object.

Fixes #1191.

The previous implementation was calling `resize_cover_to_small` within
the context manager that was writing the image to the filesystem. This
was causing `PIL` to raise an error because it could not identify the
open and temporarily created file as a valid image.

Instead of saving the original image to the filesystem and then resizing
it, we now open the image in memory, resize it, and then save it to the
filesystem. We also avoid reading the `BytesIO` object twice by saving
small and big images from the same initial `Image` object.

Fixes #1191.
Copy link

Test Results

81 tests   81 ✅  25s ⏱️
 1 suites   0 💤
 1 files     0 ❌

Results for commit a9ac322.

Copy link
Member

@gantoine gantoine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@adamantike adamantike merged commit a594eff into master Oct 12, 2024
8 checks passed
@adamantike adamantike deleted the fix-save-small-artworks branch October 12, 2024 16:34
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 this pull request may close these issues.

2 participants