Skip to content

Instantly share code, notes, and snippets.

View sou-long's full-sized avatar

Sou Long sou-long

View GitHub Profile
@sou-long
sou-long / example.ts
Last active July 19, 2024 07:28
Dodging all the bullets with @imgly/background-removal-node
import fs from 'node:fs'
import path from 'node:path'
import url from 'node:url'
import {removeBackground} from '@imgly/background-removal-node'
const P = (...vs: string[]) => path.resolve(...vs)
async function remove_bg(filename: string) {
const prj_dir = P(url.fileURLToPath(import.meta.url), '../..') // assuming we're in src/foo.ts
const dist_dir = P(prj_dir, 'node_modules/@imgly/background-removal-node/dist')