mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user