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

Add entropy calculation #115

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

Add entropy calculation #115

wants to merge 1 commit into from

Conversation

clelland
Copy link
Collaborator

@clelland clelland commented Aug 31, 2023

This adds a simple calculation of image entropy, defined as the number of bytes in the image resource, divided by the rendered size of the image. If an image fails to meet the entropy threshold, then it is excluded as an LCP candidate image.

Closes: #72, #86


Preview | Diff

This adds a simple calculation of image entropy, defined as the number of bytes
in the image resource, divided by the rendered size of the image. If an image
fails to meet the entropy threshold, then it is excluded as an LCP candidate
image.

Closes: #86
@clelland clelland requested a review from yoavweiss August 31, 2023 16:46
@clelland
Copy link
Collaborator Author

Open question - should the threshold be left as implementation-defined? This calculation could be effectively skipped by setting it to 0, if an implementor wanted to ignore entropy.

@sefeng211
Copy link

Ian, is there anything prevent this from landing? I think we can start with 0.05 for now to make sure all implementations have the same value. If we want to allow implementations to ignore entropy, maybe we can specify this feature is optional rather than making entropy itself to be implementation-defined.

@clelland

@clelland
Copy link
Collaborator Author

I think that question was the only reason I hadn't landed it yet. I can add a word or two to make the step optional if the implementation doesn't want to consider entropy (if you think that's useful -- or else we can just make it part of the definition)

@sefeng211
Copy link

Maybe just part of the definition I think?

@sefeng211
Copy link

@clelland Ian, do you have data about how often an low entropy image is detected? Or how useful is this? Or any data related to how the threshold was picked? Thanks!

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.

Very large transparent SVG should not count as LCP
2 participants