Frameright / Frameright/image-display-control-web-component
Option for automatically parsing metadata
- Dominant language
- TypeScript
- Stars
- 18
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
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](https://codesandbox.io/s/image-display-control-web-component-6hzmq5):
```js
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked CodeSandbox and the ImageDisplayControl.Parser API to understand the existing metadata flow. Then inspect the web component entry point and determine how the requested flag should trigger parsing when the parser is loaded. Done means the component can populate data-image-regions automatically; localStorage caching is an optional stretch goal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100