Sitelet https://github.com/gpodder/gpodder/pull/1107
Skip to content

gtkui: refactor resize_pixbuf_keep_ratio - #1107

Merged
auouymous merged 1 commit into
gpodder:masterfrom
ollieparanoid:refactor-resize-pixbuf
Jul 26, 2021
Merged

auouymous merged 1 commit into
gpodder:masterfrom
ollieparanoid:refactor-resize-pixbuf

Conversation

@ollieparanoid

Copy link
Copy Markdown
Contributor

Do all image size calculation before calling scale_simple, so it only
needs to be called once.

Add a debug log message, since scaling cover images actually takes some
time and it's good to know the target resolution. (On my PinePhone,
scaling these cover images delays startup significantly and thumbnails
are too small when the program is scaled in the Phosh UI).

While at it, return early if no resize is needed so the changed and
result variables can be removed.

Calling scale_simple twice happens with the previous code, if the height
of the source image is greater than max_image_side and greater than the
width. In that case, the resulting image has less quality since the
second scale_simple already works with a scaled down image and scaling
takes twice as long. In practice most podcasts have square artwork so
I assume this didn't have much of a practical effect. But I care about
the log message and figured this would be the most elegant way to add it.

@auouymous

Copy link
Copy Markdown
Member

Other than that, it LGTM, I just need to test it.

@ollieparanoid

Copy link
Copy Markdown
Contributor Author

Other than that, it LGTM, I just need to test it.

Other than what? :) Sounds like a review comment was not submitted yet?

Comment thread src/gpodder/gtkui/model.py Outdated
Do all image size calculation before calling scale_simple, so it only
needs to be called once.

Add a debug log message, since scaling cover images actually takes some
time and it's good to know the target resolution. (On my PinePhone,
scaling these cover images delays startup significantly and thumbnails
are too small when the program is scaled in the Phosh UI).

While at it, return early if no resize is needed so the changed and
result variables can be removed.

Calling scale_simple twice happens with the previous code, if the height
of the source image is greater than max_image_side and greater than the
width. In that case, the resulting image has less quality since the
second scale_simple already works with a scaled down image and scaling
takes twice as long. In practice most podcasts have square artwork so
I assume this didn't have much of a practical effect. But I care about
the log message and figured this would be the most elegant way to add it.
@ollieparanoid
ollieparanoid force-pushed the refactor-resize-pixbuf branch from ed9c746 to d8d68e1 Compare July 24, 2021 07:23
@ollieparanoid
ollieparanoid requested a review from auouymous July 24, 2021 07:25
@auouymous
auouymous merged commit dd3a802 into gpodder:master Jul 26, 2021
@auouymous

Copy link
Copy Markdown
Member

Thanks for the patch, it will improve the performance of a feature I'm working on.

auouymous added a commit to auouymous/gpodder that referenced this pull request Aug 15, 2021
elelay added a commit that referenced this pull request Aug 18, 2021
Move scale_pixbuf to util.py and apply #1107 refactoring.
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