@markerjs/markerjs3 3.6.2 → 3.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -24
- package/README.md +106 -106
- package/markerjs3.js +1 -1
- package/markerjs3.js.map +1 -1
- package/package.json +1 -1
- package/umd/markerjs3.js +1 -1
- package/umd/markerjs3.js.map +1 -1
package/LICENSE
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
marker.js 3 Linkware License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Alan Mendelevich
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
1. The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
2. Link back to the Software website displayed during operation of the Software
|
|
16
|
-
or an equivalent prominent public attribution must be retained. Alternative
|
|
17
|
-
commercial licenses can be obtained to remove this clause.
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
marker.js 3 Linkware License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Alan Mendelevich
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
1. The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
2. Link back to the Software website displayed during operation of the Software
|
|
16
|
+
or an equivalent prominent public attribution must be retained. Alternative
|
|
17
|
+
commercial licenses can be obtained to remove this clause.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
25
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
# marker.js 3 — Add image annotation to your web apps
|
|
2
|
-
|
|
3
|
-
marker.js 3 is a JavaScript browser library to enable image annotation in your web applications. Add marker.js 3 to your web app and enable users to annotate and mark up images. You can save, share or otherwise process the results.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @markerjs/markerjs3
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
The library includes TypeScript type definitions out of the box.
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
marker.js 3 is a "headless" library. In this case "headless" means that it doesn't come with any toolbars, property editors, and placement preconceptions. This way the library focuses on the core features you need, and you can make it feel totally native in the application you are building without resorting to any tricks or hacks.
|
|
16
|
-
|
|
17
|
-
With that out of the way, here are the simplest usage scenarios...
|
|
18
|
-
|
|
19
|
-
### MarkerArea (The Editor)
|
|
20
|
-
|
|
21
|
-
Import `MarkerArea` from `@markerjs/markerjs3`:
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
import { MarkerArea } from '@markerjs/markerjs3';
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
In the code below we assume that you have an `HTMLImageElement` as `targetImage`. It can be a reference to an image you already have on the page or you can simply create it with something like this:
|
|
28
|
-
|
|
29
|
-
```js
|
|
30
|
-
const targetImg = document.createElement('img');
|
|
31
|
-
targetImg.src = './sample.jpg';
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Now you just need to create an instance of `MarkerArea`, set its `targetImage` property and add it to the page:
|
|
35
|
-
|
|
36
|
-
```js
|
|
37
|
-
const markerArea = new MarkerArea();
|
|
38
|
-
markerArea.targetImage = targetImg;
|
|
39
|
-
editorContainerDiv.appendChild(markerArea);
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
To initiate creation of a marker you just call `createMarker()` and pass it the name (or type) of the marker you want to create. So, if you have a button with id `addFrameButton` you can make it create a new `FrameMarker` with something like this:
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
document.querySelector('#addButton')?.addEventListener('click', () => {
|
|
46
|
-
markerArea.createMarker('FrameMarker');
|
|
47
|
-
});
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
And whenever you want to save state (current annotation) you just call `getState()`:
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
document.querySelector('#saveStateButton')?.addEventListener('click', () => {
|
|
54
|
-
const state = markerArea.getState();
|
|
55
|
-
console.log(state);
|
|
56
|
-
});
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Rendering static images
|
|
60
|
-
|
|
61
|
-
To render the annotation as a static image you use `Renderer`.
|
|
62
|
-
|
|
63
|
-
```js
|
|
64
|
-
import { MarkerArea, Renderer } from '@markerjs/markerjs3';
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Just create an instance of it and pass the annotation state to the `rasterize()` method:
|
|
68
|
-
|
|
69
|
-
```js
|
|
70
|
-
const renderer = new Renderer();
|
|
71
|
-
renderer.targetImage = targetImg;
|
|
72
|
-
const dataUrl = await renderer.rasterize(markerArea.getState());
|
|
73
|
-
|
|
74
|
-
const img = document.createElement('img');
|
|
75
|
-
img.src = dataUrl;
|
|
76
|
-
|
|
77
|
-
someDiv.appendChild(img);
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### MarkerView (The Viewer)
|
|
81
|
-
|
|
82
|
-
To show dynamic annotation overlays on top of the original image you use `MarkerView`.
|
|
83
|
-
|
|
84
|
-
```js
|
|
85
|
-
import { MarkerView } from '@markerjs/markerjs3';
|
|
86
|
-
|
|
87
|
-
const markerView = new MarkerView();
|
|
88
|
-
markerView.targetImage = targetImg;
|
|
89
|
-
viewerContainer.appendChild(markerView);
|
|
90
|
-
|
|
91
|
-
markerView.show(savedState);
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Demos
|
|
95
|
-
|
|
96
|
-
Check out the [demos on markerjs.com](https://markerjs.com/demos).
|
|
97
|
-
|
|
98
|
-
## More docs and tutorials
|
|
99
|
-
|
|
100
|
-
You can find marker.js 3 reference and tutorials [here](https://markerjs.com/docs-v3/).
|
|
101
|
-
|
|
102
|
-
## License
|
|
103
|
-
|
|
104
|
-
Linkware (see [LICENSE](https://github.com/ailon/markerjs3/blob/master/LICENSE) for details) - the UI displays a small link back to the marker.js 3 website which should be retained.
|
|
105
|
-
|
|
106
|
-
Alternative licenses are available through the [marker.js website](https://markerjs.com).
|
|
1
|
+
# marker.js 3 — Add image annotation to your web apps
|
|
2
|
+
|
|
3
|
+
marker.js 3 is a JavaScript browser library to enable image annotation in your web applications. Add marker.js 3 to your web app and enable users to annotate and mark up images. You can save, share or otherwise process the results.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @markerjs/markerjs3
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The library includes TypeScript type definitions out of the box.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
marker.js 3 is a "headless" library. In this case "headless" means that it doesn't come with any toolbars, property editors, and placement preconceptions. This way the library focuses on the core features you need, and you can make it feel totally native in the application you are building without resorting to any tricks or hacks.
|
|
16
|
+
|
|
17
|
+
With that out of the way, here are the simplest usage scenarios...
|
|
18
|
+
|
|
19
|
+
### MarkerArea (The Editor)
|
|
20
|
+
|
|
21
|
+
Import `MarkerArea` from `@markerjs/markerjs3`:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { MarkerArea } from '@markerjs/markerjs3';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
In the code below we assume that you have an `HTMLImageElement` as `targetImage`. It can be a reference to an image you already have on the page or you can simply create it with something like this:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
const targetImg = document.createElement('img');
|
|
31
|
+
targetImg.src = './sample.jpg';
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Now you just need to create an instance of `MarkerArea`, set its `targetImage` property and add it to the page:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
const markerArea = new MarkerArea();
|
|
38
|
+
markerArea.targetImage = targetImg;
|
|
39
|
+
editorContainerDiv.appendChild(markerArea);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
To initiate creation of a marker you just call `createMarker()` and pass it the name (or type) of the marker you want to create. So, if you have a button with id `addFrameButton` you can make it create a new `FrameMarker` with something like this:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
document.querySelector('#addButton')?.addEventListener('click', () => {
|
|
46
|
+
markerArea.createMarker('FrameMarker');
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
And whenever you want to save state (current annotation) you just call `getState()`:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
document.querySelector('#saveStateButton')?.addEventListener('click', () => {
|
|
54
|
+
const state = markerArea.getState();
|
|
55
|
+
console.log(state);
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Rendering static images
|
|
60
|
+
|
|
61
|
+
To render the annotation as a static image you use `Renderer`.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
import { MarkerArea, Renderer } from '@markerjs/markerjs3';
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Just create an instance of it and pass the annotation state to the `rasterize()` method:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
const renderer = new Renderer();
|
|
71
|
+
renderer.targetImage = targetImg;
|
|
72
|
+
const dataUrl = await renderer.rasterize(markerArea.getState());
|
|
73
|
+
|
|
74
|
+
const img = document.createElement('img');
|
|
75
|
+
img.src = dataUrl;
|
|
76
|
+
|
|
77
|
+
someDiv.appendChild(img);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### MarkerView (The Viewer)
|
|
81
|
+
|
|
82
|
+
To show dynamic annotation overlays on top of the original image you use `MarkerView`.
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
import { MarkerView } from '@markerjs/markerjs3';
|
|
86
|
+
|
|
87
|
+
const markerView = new MarkerView();
|
|
88
|
+
markerView.targetImage = targetImg;
|
|
89
|
+
viewerContainer.appendChild(markerView);
|
|
90
|
+
|
|
91
|
+
markerView.show(savedState);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Demos
|
|
95
|
+
|
|
96
|
+
Check out the [demos on markerjs.com](https://markerjs.com/demos).
|
|
97
|
+
|
|
98
|
+
## More docs and tutorials
|
|
99
|
+
|
|
100
|
+
You can find marker.js 3 reference and tutorials [here](https://markerjs.com/docs-v3/).
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
Linkware (see [LICENSE](https://github.com/ailon/markerjs3/blob/master/LICENSE) for details) - the UI displays a small link back to the marker.js 3 website which should be retained.
|
|
105
|
+
|
|
106
|
+
Alternative licenses are available through the [marker.js website](https://markerjs.com).
|