Skip to content

Commit 3452bf7

Browse files
Merge pull request #216 from SenteraLLC/feature/size-mode
[PLAT-1279] Feature/size mode
2 parents 1b7eeb1 + 2cbeafc commit 3452bf7

14 files changed

Lines changed: 116 additions & 127 deletions

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented here.
55
## [unreleased]
66

77
Nothing yet.
8+
## [0.17.0] - May 30th, 2025
9+
- Add `anno_scaling_mode` argument to the `ULabel` constructor, which allows users to specify how the size of annotations should be scaled when the zoom level is changed.
10+
- Options are `fixed`, `match-zoom`, and `inverse-zoom`.
11+
- When set to `fixed`, the line size of annotations will remain constant regardless of zoom level.
12+
- When set to `match-zoom`, the line size of annotations will increase with increased zoom level.
13+
- When set to `inverse-zoom`, the line size of annotations will decrease with increased zoom level.
14+
- Prior behavior is equivalent to `anno_scaling_mode = "fixed"`.
15+
- Fix bug where fully erased polygon annotations would cause the an error upon submit.
816

917
## [0.16.4] - May 2nd, 2025
1018
- Fix bug where empty polygon layers could be included in a `submit_button` hook payload.

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ULabel is an entirely "frontend" tool. It can be incorporated into any HTML page
1414
<script src="https://unpkg.com/ulabel/dist/ulabel.js"></script>
1515
```
1616

17-
Or you can use npm to install it and serve the `dist/ulabel.js` file from `node_modules` locally.
17+
ULabel is also published on [npm](https://www.npmjs.com/package/ulabel). You can use npm to install it and serve the `dist/ulabel.js` file from `node_modules` locally.
1818

1919
```bash
2020
npm install ulabel
@@ -24,6 +24,12 @@ npm install ulabel
2424
<script src="/node_modules/ulabel/dist/ulabel.js"></script>
2525
```
2626

27+
Or you can import it directly in your JavaScript code:
28+
29+
```javascript
30+
import ULabel from 'ulabel';
31+
```
32+
2733
An API spec can be found [here](https://github.com/SenteraLLC/ulabel/blob/main/api_spec.md), but as a brief overview: Once the script is included in your HTML doc, you can create a ULabel annotation session as follows.
2834

2935
```html

api_spec.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,15 @@ In some cases, you may want the annotations to render at a higher or lower resol
305305
306306
### `initial_line_size`
307307
308-
The line width with which new annotations are drawn initially. Units are pixels in the underlying image. When this value is not included, the default value of `4` is used and scaled by the current zoom value when a new annotation is drawn. When an `initial_line_size` is included, it is used as the line width for new annotations regardless of the current zoom value.
308+
The line width with which new annotations are drawn initially. Units are pixels in the underlying image. When this value is not included, the default value of `4` is used.
309+
310+
### `anno_scaling_mode`
311+
312+
Defines how annotation line size is adjusted based on the zoom level. The following modes are supported:
313+
314+
- `"fixed"`: Line size remains constant regardless of zoom level. (Default. Use for best performance)
315+
- `"match-zoom"`: Line size increases with increased zoom level.
316+
- `"inverse-zoom"`: Line size decreases with increased zoom level.
309317
310318
### `instructions_url`
311319

demo/multi-class.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"toggle_brush_mode_keybind": "f",
132132
"create_bbox_on_initial_crop": "|",
133133
"click_and_drag_poly_annotations": false,
134+
"anno_scaling_mode": "match-zoom",
134135
});
135136
// Wait for ULabel instance to finish initialization
136137
ulabel.init(function () {

demo/resume-from.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@
246246
"image_data": "https://ulabel.s3.us-east-2.amazonaws.com/cs-demo-0.png",
247247
"username": "DemoUser",
248248
"submit_buttons": on_submit,
249-
"subtasks": subtasks
249+
"subtasks": subtasks,
250+
"anno_scaling_mode": "inverse-zoom",
250251
});
251252
// Wait for ULabel instance to finish initialization
252253
ulabel.init(function() {

dist/ulabel.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ulabel.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ export type ImageData = {
166166
frames: string[];
167167
};
168168

169+
export type AnnoScalingMode = "fixed" | "inverse-zoom" | "match-zoom";
170+
169171
export type ULabelSubtasks = { [key: string]: ULabelSubtask };
170172

171173
export class ULabel {
@@ -182,7 +184,7 @@ export class ULabel {
182184
current_subtask: string;
183185
last_brush_stroke: [number, number];
184186
line_size: number;
185-
size_mode: string; // TODO (joshua-dean): use enum
187+
anno_scaling_mode: AnnoScalingMode;
186188
// Render state
187189
// TODO (joshua-dean): this is never assigned, is it used?
188190
demo_canvas_context: CanvasRenderingContext2D;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ulabel",
33
"description": "An image annotation tool.",
4-
"version": "0.16.4",
4+
"version": "0.17.0",
55
"main": "dist/ulabel.js",
66
"module": "dist/ulabel.js",
77
"scripts": {

0 commit comments

Comments
 (0)