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

DOP-4207: pre determine image dimensions in parser #547

Merged
merged 7 commits into from
Jan 9, 2024
Merged

Conversation

seungpark
Copy link
Collaborator

@seungpark seungpark commented Jan 3, 2024

Goal: Add width and height properties to images and figures such that the AST contains these dimensions in order for snooty to lazy load images in the same dimension.

I added this package as a lightweight image size getter, but open to suggestion such as PIL.

Package has been installed via CLI command poetry add [email protected] which updated pyproject.toml and poetry.lock subsequently.

Example of staged changes with frontend branch

Note:

  • added a diagnostics property to static_asset so that any errors while getting image dimensions will appended to the parser's diagnostics. ex:
WARNING(core/csfle/reference/encryption-components.txt:0ish): WARNING! Intrinsic size for image not calculated at path /Users/seung.park/Desktop/doc-repos/docs-mongodb-internal/source/images/client-side-field-level-encryption-diagram.svg. Image may not be lazy loaded.

Question:

Copy link
Contributor

@i80and i80and left a comment

Choose a reason for hiding this comment

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

Nice! I've wanted this to happen for a while, so it's nice to see this done!

@seungpark seungpark requested a review from i80and January 4, 2024 20:00
@seungpark seungpark merged commit f0bc4cf into main Jan 9, 2024
6 checks passed
@seungpark seungpark deleted the DOP-4207 branch January 9, 2024 15:24
@@ -159,6 +159,10 @@ def __call__(
try:
checksum = self.asset.get_checksum()
options["checksum"] = checksum
dimensions = self.asset.dimensions
if dimensions is not None:
options["width"] = str(dimensions[0])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@i80and seems like this will overwrite some input user data (ie. width option). validating this is None before overwriting in a follow up PR

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