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

Option for automatically parsing metadata #17

Open
lourot opened this issue Jul 5, 2023 · 0 comments
Open

Option for automatically parsing metadata #17

lourot opened this issue Jul 5, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@lourot
Copy link
Member

lourot commented Jul 5, 2023

In order to populate data-image-regions=, if parsing image metadata on the front-end is good enough, one has to write a bit of boilerplate at the moment, as shown in the CodeSandbox:

        const imgElement = document.getElementById("skater");
        const image = await fetch(imgElement.src);
        const arrayBuffer = await image.arrayBuffer();
        const buffer = Buffer.Buffer.from(arrayBuffer);
        const parser = new ImageDisplayControl.Parser(buffer);
        const regions = parser.getIdcMetadata("rectangle", "crop");
        imgElement.dataset.imageRegions = JSON.stringify(regions);

It would be nice to be able to pass a flag to the web-component telling it to do this for us, if ImageDisplayControl.Parser exists, i.e. if https://github.com/Frameright/image-display-control-metadata-parser has been loaded.

Possible optimization / strech goal

We could then store the parsed metadata in the localstorage in order not to have to parse it again. We need to find a cheap way though to determine when what we have cached is stale.

@lourot lourot added the enhancement New feature or request label Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant