mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat(image-engine): add Sharp wrapper with 14 image operations
Operations: resize, crop, rotate, flip, convert, compress, strip-metadata, brightness, contrast, saturation, color-channels, grayscale, sepia, invert. Includes format detection, MIME mapping, metadata parsing, and engine orchestrator.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import sharp from "sharp";
|
||||
import type { ImageInfo } from "../types.js";
|
||||
|
||||
/**
|
||||
* Extract comprehensive image metadata from a buffer.
|
||||
*/
|
||||
export async function getImageInfo(buffer: Buffer): Promise<ImageInfo> {
|
||||
const metadata = await sharp(buffer).metadata();
|
||||
|
||||
return {
|
||||
width: metadata.width ?? 0,
|
||||
height: metadata.height ?? 0,
|
||||
format: metadata.format ?? "unknown",
|
||||
channels: metadata.channels ?? 0,
|
||||
size: buffer.length,
|
||||
hasAlpha: metadata.hasAlpha ?? false,
|
||||
metadata: {
|
||||
space: metadata.space,
|
||||
density: metadata.density,
|
||||
isProgressive: metadata.isProgressive,
|
||||
hasProfile: metadata.hasProfile,
|
||||
orientation: metadata.orientation,
|
||||
exif: metadata.exif ? true : false,
|
||||
icc: metadata.icc ? true : false,
|
||||
xmp: metadata.xmp ? true : false,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user