mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
- Add Cloudflare Pages deployment for landing page (snapotter.com) and docs (docs.snapotter.com) - Create deploy-landing.yml and update deploy-docs.yml workflows - Update CI to ignore apps/landing/** paths - Fix logo transparency (remove white background) across all apps - Recreate social-preview.png with SnapOtter branding - Update all docs URLs from GitHub Pages to docs.snapotter.com - Update VitePress config: light theme default, fix llms.txt paths - Add .vitepress/cache/ and .env.* to gitignore
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { flip, rotate } from "@snapotter/image-engine";
|
|
import type { FastifyInstance } from "fastify";
|
|
import sharp from "sharp";
|
|
import { z } from "zod";
|
|
import { createToolRoute } from "../tool-factory.js";
|
|
|
|
const settingsSchema = z.object({
|
|
angle: z.number().default(0),
|
|
horizontal: z.boolean().default(false),
|
|
vertical: z.boolean().default(false),
|
|
});
|
|
|
|
export function registerRotate(app: FastifyInstance) {
|
|
createToolRoute(app, {
|
|
toolId: "rotate",
|
|
settingsSchema,
|
|
process: async (inputBuffer, settings, filename) => {
|
|
let image = sharp(inputBuffer);
|
|
|
|
// Apply rotation first
|
|
if (settings.angle !== 0) {
|
|
image = await rotate(image, { angle: settings.angle });
|
|
}
|
|
|
|
// Then apply flip/flop
|
|
if (settings.horizontal || settings.vertical) {
|
|
image = await flip(image, {
|
|
horizontal: settings.horizontal,
|
|
vertical: settings.vertical,
|
|
});
|
|
}
|
|
|
|
const buffer = await image.toBuffer();
|
|
return { buffer, filename, contentType: "image/png" };
|
|
},
|
|
});
|
|
}
|