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:
@@ -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(),
|
||||
});
|
||||
Reference in New Issue
Block a user