Files
SnapOtter/apps/api/src/routes/tools/rotate.ts
T
Siddharth Kumar Sah 85b1cfc10a chore: rename Stirling-Image to ashim across entire codebase
Complete rebrand from Stirling-Image to ashim following the project
move to https://github.com/ashim-hq/ashim.

Changes across 117 files:
- Package scope: @stirling-image/* → @ashim/*
- GitHub URLs: stirling-image/stirling-image → ashim-hq/ashim
- Docker Hub: stirlingimage/stirling-image → ashimhq/ashim
- GitHub Pages: stirling-image.github.io → ashim-hq.github.io
- All branding text: "Stirling Image" → "ashim"
- Docker service/volumes/user: stirling → ashim
- Database: stirling.db → ashim.db
- localStorage keys: stirling-token → ashim-token
- Environment variables: STIRLING_GPU → ASHIM_GPU
- Python cache dirs: .cache/stirling-image → .cache/ashim
- SVG filter IDs, test prefixes, and all other references
2026-04-14 20:55:42 +08:00

38 lines
1.0 KiB
TypeScript

import { flip, rotate } from "@ashim/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" };
},
});
}