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

Support loading images from urls without extensions #163

Merged
merged 3 commits into from
Apr 14, 2024
Merged

Conversation

jonmmease
Copy link
Collaborator

Closes #162

The issue was that this tile provider serves images in jpg format, but the URLs do not include a file extension (e.g. https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/5/14/17) and usvg uses the file extension to infer the image type. This PR adds logic to infer the image type from the Content-Type header and use that to build a file extension that usvg is happy with.

cc @binste

```
RUST_LOG=vl_convert
RUST_LOG=info
```
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This way logging info for usvg is displayed as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

update to cargo-bundle-license crate

return None;
};
get_text_width_from_path(node)
get_text_width_from_path(text.convert(font_db, Default::default())?)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

clippy fix

@@ -29,21 +29,18 @@ pub type ImageHrefStringResolverFn = Box<dyn Fn(&str, &Options) -> Option<ImageK
pub fn custom_string_resolver() -> ImageHrefStringResolverFn {
let default_string_resolver = ImageHrefResolver::default_string_resolver();
Box::new(move |href: &str, opts: &Options| {
info!("Resolving image: {href}");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added logging

@jonmmease jonmmease merged commit 2ece4bc into main Apr 14, 2024
10 checks passed
@jonmmease jonmmease deleted the jonmmease/gh162 branch April 14, 2024 21:18
@mattijn
Copy link

mattijn commented Apr 16, 2024

Very clever solution! Really cool to read your code🙌

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.

altair_tiles: Tiles are missing in PNG export but works with SVG
2 participants