Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save documentprocessing/de1ddb355d01c3a729555ccc95a9407a to your computer and use it in GitHub Desktop.
Save documentprocessing/de1ddb355d01c3a729555ccc95a9407a to your computer and use it in GitHub Desktop.
Add annotations to images manually or automatically using JSON in JavaScript using Annotorious Library. Check https://products.documentprocessing.com/annotation/javascript/annotorious/ for more details.
<html>
<head>
<!-- Linking Annotorious Stylesheet -->
<link rel="stylesheet" href="dist/annotorious.min.css">
<!-- Integrating Annotorious JavaScript Library -->
<script type="text/javascript" src="dist/annotorious.min.js"></script>
</head>
<body>
<!-- Image on which annotations will be added -->
<div id="imageContainer">
<img id="image" src="image.jpg" />
</div>
<script>
(function () {
// Initialize Annotorious with the image for annotations
var anno = Annotorious.init({ image: "image" });
})()
</script>
</body>
</html>
<html>
<head>
<!-- Linking Annotorious Stylesheet -->
<link rel="stylesheet" href="dist/annotorious.min.css">
<!-- Integrating Annotorious JavaScript Library -->
<script type="text/javascript" src="dist/annotorious.min.js"></script>
</head>
<body>
<!-- Image on which annotations will be added -->
<div id="imageContainer">
<img id="image" src="image.jpg" />
</div>
<script>
(function () {
// Initialize Annotorious with the image for annotations
var anno = Annotorious.init({ image: "image" });
// Load JSON file containing annotations data
anno.loadAnnotations('annotations.json');
})()
</script>
</body>
</html>
[
{
"@context": "http://www.w3.org/ns/anno.jsonld",
"id": "#a88b22d0-6106-4872-9435-c78b5e89fede",
"type": "Annotation",
"body": [{
"type": "TextualBody",
"value": "Tower 1"
}, {
"type": "TextualBody",
"purpose": "tagging",
"value": "Ancient buildings"
}],
"target": {
"selector": [{
"type": "FragmentSelector",
"conformsTo": "http://www.w3.org/TR/media-frags/",
"value": "xywh=pixel:2140,60,800,2000"
}]
}
}, {
"type": "Annotation",
"body": [
{
"type": "TextualBody",
"value": "Tip of the biggest dome",
"purpose": "commenting"
}
],
"target": {
"selector": {
"type": "FragmentSelector",
"conformsTo": "http://www.w3.org/TR/media-frags/",
"value": "xywh=pixel:3050,770,0,0"
},
"renderedVia": {
"name": "point"
}
},
"@context": "http://www.w3.org/ns/anno.jsonld",
"id": "#9a4c10df-3c07-40c3-9108-672d1194bbf8"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment