1. Go to this page and download the library: Download survos/iiif-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
survos / iiif-bundle example snippets
use Survos\IiifBundle\Builder\ManifestBuilder;
use Survos\IiifBundle\Model\ImageService3;
use Survos\IiifBundle\Enum\ViewingDirection;
use Survos\IiifBundle\Enum\Behavior;
$builder = new ManifestBuilder('https://example.org/iiif/item-123/manifest');
$builder
->setLabel('en', 'Civil War Pension File — Pvt. James Wilson')
->setSummary('en', 'Pension application including affidavits and medical examination, 1892')
->addMetadata('en', 'Date', 'en', '1892')
->addMetadata('en', 'Creator', 'en', 'U.S. Pension Bureau')
->setRights('http://creativecommons.org/publicdomain/mark/1.0/')
->setRequiredStatement('en', 'Attribution', 'Courtesy of Carver 4-County Museum')
->setViewingDirection(ViewingDirection::LEFT_TO_RIGHT)
->setBehavior(Behavior::PAGED);
// Add pages as canvases
foreach ($pages as $i => $page) {
$canvas = $builder->addCanvas(
id: "https://example.org/iiif/item-123/canvas/p{$i}",
label: "Page {$i}",
width: $page->getWidth(),
height: $page->getHeight(),
);
// Paint the image onto the canvas
$canvas->addImage(
annotationId: "https://example.org/iiif/item-123/canvas/p{$i}/anno/image",
imageUrl: "https://s3.example.org/scans/item-123/page-{$i}.jpg",
format: 'image/jpeg',
width: $page->getWidth(),
height: $page->getHeight(),
service: new ImageService3(
id: "https://iiif.example.org/image/item-123-page-{$i}",
profile: 'level2'
),
);
// Add full-page OCR text as supplementing annotation
$canvas->addSupplementingText(
annotationId: "https://example.org/iiif/item-123/canvas/p{$i}/ocr/fulltext",
text: $page->getOcrText(),
language: 'en',
);
// Add word-level OCR annotations for search highlighting
foreach ($page->getOcrWords() as $word) {
$canvas->addWordAnnotation(
annotationId: "https://example.org/iiif/item-123/canvas/p{$i}/ocr/word-" . $word->getId(),
text: $word->getText(),
language: 'en',
x: $word->getX(),
y: $word->getY(),
width: $word->getWidth(),
height: $word->getHeight(),
);
}
}
// Add Content Search service (Meilisearch-backed)
$builder->addSearchService('https://example.org/iiif/item-123/search');
// Serialize to JSON
$json = $builder->toJson();
$array = $builder->toArray();
IiifUrl::isImageApiEndpoint($url); // true only for real IIIF (contains /iiif/ or ends /info.json)
IiifUrl::imageUrl($base); // real IIIF → "$base/full/max/0/default.jpg"
// direct image → "$base" unchanged
IiifUrl::imageUrl($base, '!300,300'); // custom IIIF size segment
use Survos\IiifBundle\Model\Manifest;
use Survos\IiifBundle\Model\Canvas;
use Survos\IiifBundle\Model\AnnotationPage;
use Survos\IiifBundle\Model\Annotation;
use Survos\IiifBundle\Model\ResourceItem;
use Survos\IiifBundle\Model\LabelMap;
use Survos\IiifBundle\Enum\Motivation;
$manifest = Manifest::create('https://example.org/manifest');
$manifest->setLabel('en', 'My Document');
$canvas = Canvas::create(
'https://example.org/canvas/1',
LabelMap::create('en', 'Page 1'),
3000,
4000
);
$annotation = Annotation::createPainting(
'https://example.org/annotation/1',
ResourceItem::createImage('https://example.org/image1.jpg', 'image/jpeg', 3000, 4000),
'https://example.org/canvas/1'
);
$annotationPage = AnnotationPage::create('https://example.org/annopage/1');
$annotationPage->addItem($annotation);
$canvas->addItem($annotationPage);
$manifest->addItem($canvas);
$json = json_encode(['@context' => 'http://iiif.io/api/presentation/3/context.json'] + $manifest->jsonSerialize(), JSON_PRETTY_PRINT);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.