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

Load image from absolute path/url #537

Closed
baransu opened this issue Aug 18, 2019 · 3 comments · Fixed by #796
Closed

Load image from absolute path/url #537

baransu opened this issue Aug 18, 2019 · 3 comments · Fixed by #796
Labels
A-components Area: Consumer-exposed components providing some convenience over the primitives enhancement New feature or request WIP

Comments

@baransu
Copy link

baransu commented Aug 18, 2019

Trying to display images from URL I found it's currently not supported. I decided to download images to some tmp directory and use an absolute path as an Image src. And that's also not supported right now:

let relativeImagePath = execDir ++ imagePath;

The best option would be to have:

type src = Url(string) | Relative(string) | Absolute(string)

which would allow loading images from /assets, any directory and URL.

I'm willing to help with that feature but I don't know what's the best approach to download image and use it as a texture in ImageRenderer.

@bryphe
Copy link
Member

bryphe commented Aug 26, 2019

Trying to display images from URL I found it's currently not supported.

Yes, this is something I'd like to have... I started a fetch-like API for Revery but haven't had time to finish it. It'd be great to get that working, and then hook up our asset resolution to detect URLs and use that automatically.

I decided to download images to some tmp directory and use an absolute path as an Image src.

Good idea as a workaround for now! I had a PR a while back for absolute paths (#242 ) but didn't finish it. I ported it over to #545 now. It's more naive - just uses a string as opposed to a variant, but I think it's OK for now (at least a step forward from what we have).

We could look at integrating the Path module here, which has a more similar API to what you proposed.

@bryphe bryphe closed this as completed in e7d236d Aug 26, 2019
@lessp
Copy link
Member

lessp commented Nov 2, 2019

Regarding URL I experimented a bit with this yesterday and got a PoC working. May be happy to take a stab at it, depending on what you are seeing!

My "get-something-running" approach was to save the images to a temporary folder, escape the url from any illegal characters and then provide that path to the renderer.

Some questions I had:

  • Do we delete temporary cached images on application-close?
  • Where do we store the temporary files? Might be platform-specific

There are probably other approaches which may be more suited, just leaving this here since I at least did some experimenting! 🙂

@Et7f3
Copy link
Member

Et7f3 commented Nov 2, 2019

Maybe let the user decide with Url(string, option(string)) and the second argument if None mean non-cached and Some(cachedPath) mean to save file to cachedPath. And provide cleaning functions: cleanAll, cleanOneFile.

@Et7f3 Et7f3 reopened this Nov 2, 2019
@lessp lessp added enhancement New feature or request WIP labels Nov 23, 2019
@glennsl glennsl added the A-components Area: Consumer-exposed components providing some convenience over the primitives label Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-components Area: Consumer-exposed components providing some convenience over the primitives enhancement New feature or request WIP
Projects
None yet
5 participants