feat(proxy): add image tracing endpoint

Add GET /trace which fetches an image, traces it into a vector shape, and returns the result BSON-encoded. Tracing is configurable via mode (alpha, bw, color) and format (shape, svg). The shape format parses the vtracer SVG into an outline/holes polygon matching @tts/mesh's Shape interface.
This commit is contained in:
2026-08-08 14:51:36 +08:00
parent d554d6bde1
commit 445dbc1781
10 changed files with 922 additions and 0 deletions
+14
View File
@@ -51,4 +51,18 @@ export const searchResultSchema = z.object({
items: z.array(workshopItemSchema),
page: z.number(),
hasMore: z.boolean(),
});
export const traceModeSchema = z.enum(['alpha', 'bw', 'color']);
export const traceFormatSchema = z.enum(['svg', 'shape']);
/** Query params for `GET /trace`. */
export const traceRequestSchema = z.object({
url: z.string().url('url must be a valid URL'),
mode: traceModeSchema.default('alpha'),
threshold: z.coerce.number().int().min(0).max(255).default(128),
format: traceFormatSchema.default('shape'),
simplify: z.coerce.number().min(0).optional(),
maxColors: z.coerce.number().int().min(1).optional(),
});