feat: make AI background removal optional with resize-only upload and batch detour selection

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-25 08:21:46 +02:00
parent c95093a81f
commit eec9bd5dce
5 changed files with 184 additions and 57 deletions
+15
View File
@@ -0,0 +1,15 @@
export async function resizeToSquare(blob: Blob, size = 1000): Promise<Blob> {
const img = await createImageBitmap(blob)
const canvas = new OffscreenCanvas(size, size)
const ctx = canvas.getContext('2d')!
ctx.fillStyle = '#ffffff'
ctx.fillRect(0, 0, size, size)
const scale = Math.min(size / img.width, size / img.height)
const w = img.width * scale
const h = img.height * scale
const x = (size - w) / 2
const y = (size - h) / 2
ctx.drawImage(img, x, y, w, h)
img.close()
return canvas.convertToBlob({ type: 'image/jpeg', quality: 0.92 })
}