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

Ensure that if method=scale the returned thumbnail is no bytesize-larger than the original image #288

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Sorunome
Copy link
Contributor

@Sorunome Sorunome commented Nov 17, 2020

This is to prevent the resulting thumbnail to be larger than the original image, which is unneeded.

@turt2live
Copy link
Member

This check would probably be better placed around here:
https://github.com/turt2live/matrix-media-repo/blob/f7546a732c1e00ea24eec73a6ceed5e1e151630a/thumbnailing/thumbnail.go#L43

If the resulting stream (buffered into memory because memory is cheap in this area) is larger than b, return b instead. It should get magically de-duped by the upper layers.

@Sorunome
Copy link
Contributor Author

Another potential issue soru thought about is how to handle animated vs non-animated: if the client requests a non-animated thumbnail but the source image is animated.

In general the thumbnail should be smaller in bytesize, but....what if not?

@turt2live turt2live changed the title Ensure that if method=scale the returned thumbnail is no bytesize-lar… Ensure that if method=scale the returned thumbnail is no bytesize-larger than the original image Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

2 participants