feat(api): add resize, crop, rotate, convert, compress, metadata, and color tool routes

Seven tool route files using the createToolRoute factory, registering 10 API
endpoints total (color adjustments covers 4 tool IDs). Also fixes the tool
factory generic to properly infer Zod output types and clamps the compress
binary-search quality to 1-100.
This commit is contained in:
Siddharth Kumar Sah
2026-03-22 03:56:34 +08:00
parent d53f6733b8
commit 37112af779
10 changed files with 313 additions and 10 deletions
@@ -48,8 +48,8 @@ async function compressToTargetSize(
const maxIterations = 8;
const tolerance = 0.05; // 5%
for (let i = 0; i < maxIterations; i++) {
const mid = Math.round((low + high) / 2);
for (let i = 0; i < maxIterations && low <= high; i++) {
const mid = Math.min(100, Math.max(1, Math.round((low + high) / 2)));
const attempt = sharp(inputBuffer).toFormat(format, { quality: mid });
const resultBuffer = await attempt.toBuffer();
const resultSize = resultBuffer.length;