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

Dynamically determine X and Y components based on aspect ratio #247

Open
simplenotezy opened this issue Nov 23, 2023 · 1 comment
Open
Labels
documentation Improvements or additions to documentation

Comments

@simplenotezy
Copy link

According to the documentation:

How do I pick the number of X and Y components?

It depends a bit on taste. The more components you pick, the more information is retained in the placeholder, but the longer the BlurHash string will be. Also, it doesn't always look good with too many components. We usually go with 4 by 3, which seems to strike a nice balance.

However, you should adjust the number of components depending on the aspect ratio of your images. For instance, very wide images should have more X components and fewer Y components.

The Swift example project contains a test app where you can play around with the parameters and see the results.

Did anybody come up with a simple formula we can use to come up with proper X and Y components dynamically based on width/height?

@jerry-git jerry-git added the documentation Improvements or additions to documentation label Jan 15, 2024
@doc-han
Copy link

doc-han commented Feb 6, 2024

I think the ideal way to automatically pick a good X and Y component will be based on the total number of components that contribute to the image and not the aspect ratio. Because aspect ratio has no info on the amount of details present in the image.

The issue involved is the fact they don't want to do the entire computation for all components in an image before making a good selection of components. It's expensive to compute for components you'll end up discarding.

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

No branches or pull requests

3 participants