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

Image API helpers #21

Merged
merged 3 commits into from
Jan 5, 2025
Merged

Image API helpers #21

merged 3 commits into from
Jan 5, 2025

Conversation

stephenwf
Copy link
Member

Ported from: https://github.com/atlas-viewer/iiif-image-api

The non-fetching work is already in the @iiif/parser/image-3 package.

Also includes a simpler (and reactive) helper:

import { imageServices } from '@iiif/helpers';
import { useStore } from 'zustand';

function SomeComponent() {
  const { loadServiceSync } = useStore(imageServices.store);
  const service = {
    id: 'https://example.org/service'
    profile: 'level2',
    ...
  };
  const image = {
    width: 1000,
    height: 1000,
  }

  // Can use inside of a render.
  // the last argument will fetch in the background.
  const service = loadServiceSync({ id: 'https://example.org/service' }, image, true); 

  return <pre>{JSON.stringify(service, null, 2)}</pre>;
}

Copy link

codesandbox-ci bot commented Jan 4, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@stephenwf stephenwf merged commit bad8886 into main Jan 5, 2025
3 checks passed
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.

1 participant