createImageProcessorOptionsValidator (endpoints/images.ts)

ruflo · ruflo/src/ruvocal/src/lib/server/endpoints/images.ts · typescript · MIT
files

Module exposing: createImageProcessorOptionsValidator, makeImageProcessor, convertImage, chooseImageSize, resizeImage, chooseMimeType, estimateImageSizeInBytes

// Source: https://github.com/ruvnet/ruflo | License: MIT | Copyright 2024-2026 ruvnet
// Provided via justclaw.it.com; keep this notice with the code.
import type { Sharp } from "sharp";
import sharp from "sharp";
import type { MessageFile } from "$lib/types/Message";
import { z, type util } from "zod";

export interface ImageProcessorOptions<TMimeType extends string = string> {
	supportedMimeTypes: TMimeType[];
	preferredMimeType: TMimeType;
	maxSizeInMB: number;
	maxWidth: number;
	maxHeight: number;
}
export type ImageProcessor<TMimeType extends string = string> = (file: MessageFile) => Promise<{
	image: Buffer;
	mime: TMimeType;
}>;

export function createImageProcessorOptionsValidator<TMimeType extends string = string>(
	defaults: ImageProcessorOptions<TMimeType>
) {
	return z
		.obj

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key