mirror of
https://github.com/ashim-hq/ashim
synced 2026-04-21 13:37:52 +00:00
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
26 lines
904 B
TypeScript
26 lines
904 B
TypeScript
import { resize } 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({
|
|
width: z.number().positive().optional(),
|
|
height: z.number().positive().optional(),
|
|
fit: z.enum(["contain", "cover", "fill", "inside", "outside"]).default("contain"),
|
|
withoutEnlargement: z.boolean().default(false),
|
|
percentage: z.number().positive().optional(),
|
|
});
|
|
|
|
export function registerResize(app: FastifyInstance) {
|
|
createToolRoute(app, {
|
|
toolId: "resize",
|
|
settingsSchema,
|
|
process: async (inputBuffer, settings, filename) => {
|
|
const image = sharp(inputBuffer);
|
|
const result = await resize(image, settings);
|
|
const buffer = await result.toBuffer();
|
|
return { buffer, filename, contentType: "image/png" };
|
|
},
|
|
});
|
|
}
|