Code Monkey home page Code Monkey logo

biiif's Introduction

biiif (build iiif) ๐Ÿ‘ทโœจ๐Ÿ“ƒ

Node version

npm i biiif --save
const { build } = require('biiif');
build('myfolder', 'http://example.com/myfolder');

Organise your files according to a simple naming convention to generate IIIF content/data using 100% node.js! IPFS compatible.

Use biiif-cli to run from a terminal.

Note: This uses the IIIF Presentation API v3, and is compatible with the Universal Viewer v3.

Github template repo for hosting IIIF on Netlify and Vercel: https://github.com/iiif-commons/biiif-template

Building static sites with biiif workshop: https://github.com/edsilv/biiif-workshop

Parameters

Parameter Type Description
folder string The source folder of your IIIF collection/manifest on disk
url string The Url to use as the root for all generated manifest, asset identifiers
virtualName string Overrides the source folder name when generating identifiers e.g. a dat archive id you need to appear in Urls instead of the source folder name

Conventions

A collection is a folder with sub-folders whose names do not start with an underscore.

A manifest is a folder with sub-folders whose names do start with an underscore.

A collection's sub-folders (no underscore) are treated as further nested collections.

A manifest's sub-folders (with underscore) are treated as canvases to add to the manifest.

Files within 'canvas folders' (.jpg, .pdf, .mp4, .obj) are annotated onto the canvas with a painting motivation.

Annotations

IIIF Presentation 3.0 uses the Web Annotation Data Model to annotate canvases.

By default, biiif will annotate any files it finds in a canvas directory (except info.yml and thumb.jpg) onto the canvas with a painting motivation.

This is handy as a quick way to generate simple manifests. However, what if you want to annotate some text onto a canvas with a commenting motivation?

Or what happens when you have obj or gltf files that require image textures to be located in the same directory? You don't want these files to be annotated onto the canvas too!

This is where custom annotations come in. Just create a file my-annotation.yml in the canvas directory and set the desired properties in that.

For example, here is my-comment.yml:

motivation: commenting
value: This is my comment on the image

Here we've excluded the type (TextualBody is assumed), and format (text/plain is assumed).

What about the gltf example? Here's how my-3d-object.yml could look:

value: assets/myobject.gltf

Here we've excluded the motivation (painting is assumed), type (Model is assumed), and format (model/gltf+json is assumed).

biiif knows that because it's a gltf file, it's likely to have all of the above values. You just need to include a value property pointing to where you've put the gltf file itself. In this case, an assets folder within the canvas directory. The associated image textures can live in the assets folder too, they won't get annotated unless you specifically ask for them to be.

Image Tile Services

biiif will automatically generate IIIF image tiles for any image it finds and put them in a +tiles directory, along with an associated info.json. The + is prepended to any directories generated by biiif and means it ignores them when generating manifests. The image service is added to the generated annotation for each image in your IIIF manifest.

Metadata

Metadata is not mandatory, but can be included as an info.yml file within a collection, manifest, or canvas folder. e.g.

label: The Lord of the Rings
description: The Lord of the Rings Trilogy
attribution: J. R. R. Tolkien
metadata:
  License: Copyright Tolkien Estate
  Author: J. R. R. Tolkien
  Published Date: 29 July 1954

Here's an example of an info.yml supplying descriptive + rights properties and metadata for a gold-broach image manifest:

https://github.com/nomadproject/objects/blob/gh-pages/collection/gold-broach/info.yml

This manifest contains a single canvas folder _gold-broach with an image to be painted onto the canvas. If there were many canvases in this manifest it might make sense to add an info.yml to each subfolder with extra image-specific metadata.

Within the info.yml you can set the label, description, and attribution descriptive and rights properties at the top-level. IIIF Presentation 3 (in beta) has renamed description to summary, and attribution to requiredStatement but these will still work in IIIF viewers.

Under these you can add a metadata section that is essentially a list of key value pairs containing any info you like (there is deliberately no specification for this as the IIIF spec writers feel it falls outside of their remit).

Thumbnails

To add a thumbnail to your collection, manifest, or canvas simply include a file named thumb.jpg (any image file extension will work) in the directory.

If no thumb image is found in a canvas directory, biiif checks to see if an image is being annotated onto the canvas with a painting motivation. If so, a thumb is generated (100 x 100px) from that.

Linked Manifests

Often it's necessary to include IIIF manifests in your collection from elsewhere. To do this, include a manifests.yml file in your collection folder e.g.

manifests:
  - id: http://test.com/collection/linkedmanifest1/index.json
    label: Linked Manifest 1
    thumbnail: http://test.com/collection/linkedmanifest1/thumb.jpg
  - id: http://test.com/collection/linkedmanifest2/index.json
    label: Linked Manifest 2
  - id: http://test.com/collection/linkedmanifest3/index.json

If you leave the label property blank, it will default to the name of the last folder in the id URL.

Including a manifests.yml file in a folder without any sub-folders forces it to behave like a collection.

Examples

A repo of test manifests: https://github.com/edsilv/biiif-test-manifests

Collection for the Nomad Project: https://github.com/nomadproject/objects

IIIF 3D manifests: https://github.com/edsilv/iiif-3d-manifests

...

Here is an example of how to organise your files/folders for biiif.

This example only has a single root collection, but biiif will happily build collections to any nested depth.

biiif will accept a manifest folder too, generating a single manifest index.json.

lord-of-the-rings                  // collection
โ”œโ”€โ”€ info.yml                       // collection metadata
โ”œโ”€โ”€ thumb.jpg                      // collection thumbnail
โ”œโ”€โ”€ 0-the-fellowship-of-the-ring   // manifest
|   โ”œโ”€โ”€ _page-1                    // canvas
|   |   โ”œโ”€โ”€ page-1.jpg             // content annotation
|   |   โ””โ”€โ”€ info.yml               // canvas metadata
|   โ”œโ”€โ”€ _page-2                    // canvas
|   |   โ”œโ”€โ”€ page-2.jpg             // content annotation
|   |   โ””โ”€โ”€ info.yml               // canvas metadata
|   โ”œโ”€โ”€ _page-n                    // canvas
|   |   โ”œโ”€โ”€ page-n.jpg             // content annotation
|   |   โ””โ”€โ”€ info.yml               // canvas metadata
|   โ”œโ”€โ”€ info.yml                   // manifest metadata
|   โ””โ”€โ”€ thumb.jpg                  // manifest thumbnail
โ”œโ”€โ”€ 1-the-two-towers               // manifest
|   โ”œโ”€โ”€ _page-1                    // canvas
|   โ”œโ”€โ”€ _page-2                    // canvas
|   โ”œโ”€โ”€ _page-n                    // canvas
|   โ”œโ”€โ”€ info.yml                   // manifest metadata
|   โ””โ”€โ”€ thumb.jpg                  // manifest thumbnail
โ””โ”€โ”€ 2-the-return-of-the-king       // manifest
โ”œโ”€โ”€ _page-1                    // canvas
โ”œโ”€โ”€ _page-2                    // canvas
โ”œโ”€โ”€ _page-n                    // canvas
โ”œโ”€โ”€ info.yml                   // manifest metadata
โ””โ”€โ”€ thumb.jpg                  // manifest thumbnail

Tips

If you need to include a folder in your project but don't want biiif to treat it as a manifest, add a ! to the start of its name, e.g. !ignorethisfolder.

Watch out for ":" in metadata descriptions, these will throw an error when parsing the YML.

biiif's People

Contributors

dependabot[bot] avatar edsilv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

biiif's Issues

Image Choice

Bearing in mind that the UX for this doesn't exist in the UV yet...

What would be the most user-friendly way to specify a choice of images? http://iiif.io/api/presentation/2.0/#choice-of-alternative-resources

If there isn't a use case for metadata on each image, you could simply list every image in the canvas folder excluding thumb.jpg. Otherwise, perhaps adding a further folder starting with an underscore could signify choice?

.biiifignore

Need to be able to ignore certain files within a canvas directory. For example, a jpg being used as a texture for a 3D model should not be annotated onto the canvas. Maybe use a .gitignore style file?

Incorrect thumbnail path

Following the biiif-template I found two issues regarding thumbnails:

  1. Root collection has /collection/ on its thumbnail path, but the image is actually at the root level:
    image

  2. Canvas thumbnail has the canvas path before the manifest path:
    image

For debugging purposes, please check this manifest: https://iiif.tiju.ca/

Can I use this in serveless?

Hi great work!,please can I use this api in a serverless context to generate iiif from a remote folder and store my index.json in s3?, thanks.
suggestion: perhaps rather than providing just a destination directory, you can explore an optional callback function that has the JSON returned as payload, for other services to explore.

On error return message

If an error is encountered, such as using @ in an info.yml value, return the error so that the UV electron app can display it.

Generate Thumbs

If there's no thumb.[jpg,png,gif] in a canvas folder, but an image is being annotated, generate a thumb using https://github.com/oliver-moran/jimp.

Use sensible defaults for dimensions, e.g. 100 x 100px.

Allow dimensions to be overridden. Maybe add an options parameter to build that accepts thumbs.width and thumbs.height properties.

build(dir, url, {
    thumbs: {
        width: 50,
        height: 50
    }
});

publish Type declaration

Hi there,

Thanks a lot for your lib.
I am using it in a TypeScript project. I can see you are using TypeScript too but unfortunately you don't publish the type declaration of your API.
It's a shame as users can't benefit form your typings and have to redeclare those locally in a biiif.d.ts with :

declare module "bifff" {
  type build = (dir: string, url: string, virtualName?: string) => Promise<void>;
}

You might consider adding typescript declaration in your build.

IIIF Presentation API v3 vs v2

I see that most recent versions of biiif state support for IIIF Presentation API v3, but I noticed that older versions seemed to be more in line with IIIF Presentation API v2. Was biiif always made to work with API v3 or was this a conscious shift?

I noticed that this commit created a big divide between v2 and v3 in the biiif code: 6e55301

But I think the README already said it was supporting v3 at that point.

Looks like your initial commit was from November 2017 and v2.1.1 was released June 2017, but I don't know when v3 docs started being created.

Judging from UniversalViewer/universalviewer#470, it looks like v3 was already well under way in June 2017?

Use items instead of sequence

Currently has:

  "id": "https://sophiedixon.github.io/3d-portfolio/collection/human_skull/index.json",
  "type": "Manifest",
  "items": [
    {
      "type": "Sequence",
      "items": [
        {
          "id": "https://sophiedixon.github.io/3d-portfolio/collection/human_skull/index.json/canvas/0",
          "type": "Canvas",

Should be:

  "id": "https://sophiedixon.github.io/3d-portfolio/collection/human_skull/index.json",
  "type": "Manifest",
  "items": [
    {
      "id": "https://sophiedixon.github.io/3d-portfolio/collection/human_skull/index.json/canvas/0",
      "type": "Canvas",

Localisable metadata

Allow setting locale in the info.yml, e.g.

-   - en
           label: The Lord of the Rings
    - de
           Etikette: Die Herr der Ringe
-   - en 
           description: The Lord of the Rings Trilogy
    - de
           Beschreibung: Die Herr der Ringe-Trilogie

Tags for releases

Would it be possible to get git tags for each release which correspond to the npm release?

Thumbnails

Put a thumb.* in canvas folders to have it set as the content annotation's thumbnail property?

Support including external manifests

Sometimes it's necessary to be able to include a manifest that has been copied from elsewhere. There is no index.json to generate in this case. Maybe include a _index.json in the folder to indicate that it can skip generating an index.json?

Add -d command

biiif myfolder -d deletes all existing index.json files.

Create manifests from a set of files without canvas folders

When someone wants to quickly test what a 3D file or image looks like in a viewer, they don't necessarily want to have to create a _myfile canvas folder. It's more convenient to simply have a folder with a single file (or set of files) in it.

When encountering a folder with a set of paintable files in it, biiif could create canvas folders for each of them before continuing.

Are canvas folders always necessary? Perhaps when encountering a folder with just paintable files in it, biif treats that as a manifest folder and generates the canvas json, leaving them in place?

Generate Ranges

Allow adding arbitrary structure grouping canvases (e.g. chapter 1, chapter 2, etc) by extending info.yml with a structures property.

label: A Book with Chapters
structures:
  - Chapter 1
    - _page1
    - _page2
    - _page3
  - Chapter 2
    - _page3
    - _page4
    - _page5

Here "Chapter 1" will be the label for the parent range, and canvases are included by their folder name. The canvas range label is retrieved using the existing label logic for canvases.

structures: [
    {
        "id": ".../index.json/ranges/range0",
        "type": "Range",
        "label": {
            "@none": [
                "Chapter 1"
            ]
        },
        "items": [
            {
                "id": "...index.json/canvases/canvas0",
                "label": {
                    "@none": [
                        "page 1"
                    ]
                },
                "type": "Canvas"
            },
            {
                "id": "...index.json/canvases/canvas1",
                "label": {
                    "@none": [
                        "page 2"
                    ]
                },
                "type": "Canvas"
            },
            {
                "id": "...index.json/canvases/canvas2",
                "label": {
                    "@none": [
                        "page 3"
                    ]
                },
                "type": "Canvas"
            }
        ]
    }
]

Custom annotations

Allow annotations with motivations other than painting on canvases.

Look for yml files in canvas folders other than info.yml. Use the name of the yml file to determine the motivation, contents of the yml file to determine the body:

commenting.yml

type: TextualBody,
value: This is a comment on the image

Instead of using a biiifignore file (#20), use a painting.yml file to control what gets annotated.

id: assets/model.gltf

model.gltf can go in _canvas/assets/ . biiif figures out the full path, type, format, and label as before.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.