aboutsummaryrefslogtreecommitdiff
path: root/src/workers/image.worker.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-08-14 11:00:14 -0400
committerbobzel <zzzman@gmail.com>2025-08-14 11:00:14 -0400
commit467f1c2543626a50d48c84669cd408571260f147 (patch)
tree2cb3599c4ca95fe2b975deb8dc72283151e1c585 /src/workers/image.worker.ts
parent5b0b7241e68febc2d0556b6c2e8349411b5c12a0 (diff)
added background removal for images.
Diffstat (limited to 'src/workers/image.worker.ts')
-rw-r--r--src/workers/image.worker.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/workers/image.worker.ts b/src/workers/image.worker.ts
new file mode 100644
index 000000000..d069742f3
--- /dev/null
+++ b/src/workers/image.worker.ts
@@ -0,0 +1,16 @@
+import { removeBackground } from '@imgly/background-removal';
+
+self.onmessage = async (event: MessageEvent) => {
+ const { imagePath, doc, addDoc } = event.data;
+
+ try {
+ // Perform the background removal
+ const result = await removeBackground(imagePath);
+
+ // Send the result back to the main thread
+ self.postMessage({ success: true, result, doc, addDoc });
+ } catch (error) {
+ // Send the error back to the main thread
+ self.postMessage({ success: false, error: (error as any).message });
+ }
+};