Skip to content

Commit

Permalink
Add image.kill property accessor
Browse files Browse the repository at this point in the history
Handy for stopping long-running computations.
  • Loading branch information
kleisauke committed Jan 28, 2024
1 parent c004099 commit 20f8414
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Uses libvips v8.15.1, compiled with Emscripten v3.1.52.

- Add `image.onProgress` callback for progress feedback.
[#63](https://github.com/kleisauke/wasm-vips/issues/63)
- Add `image.kill` property accessor to block evaluation.

## [v0.0.7] - 2023-11-12

Expand Down
5 changes: 5 additions & 0 deletions build/preamble_vips.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ declare module Vips {
*/
readonly filename: string;

/**
* Block evaluation on this image.
*/
kill: boolean;

/**
* Attach progress feedback.
*
Expand Down
5 changes: 5 additions & 0 deletions lib/vips.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/bindings/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ class Image : public Object {
return vips_image_get_filename(get_image());
}

bool is_killed() const {
return vips_image_iskilled(get_image());
}

void set_kill(bool kill) {
vips_image_set_kill(get_image(), kill ? 1 : 0);
}

static void eval_handler(VipsImage *image, VipsProgress *progress,
void *user);

Expand Down
1 change: 1 addition & 0 deletions src/vips-emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ EMSCRIPTEN_BINDINGS(my_module) {
.property("yres", &Image::yres)
.property("filename", &Image::filename)
// Handwritten setters
.property("kill", &Image::is_killed, &Image::set_kill)
.property("onProgress", &Image::stub_getter,
&Image::set_progress_callback)
// Auto-generated (class-)functions
Expand Down

0 comments on commit 20f8414

Please sign in to comment.