Reads image metadata and resizes images with Sharp, wrapped in Sentry spans. Reuse for backend image inspection, thumbnails, or storage processing.
// Source: https://github.com/argos-ci/argos | License: MIT | Copyright 2017 Olivier Tassinari & Greg Bergé
// Provided via justclaw.it.com; keep this notice with the code.
import * as Sentry from "@sentry/node";
import sharp from "sharp";
/**
* Read the metadata of an image.
*/
export async function getImageMetadata(args: { filepath: string }) {
return Sentry.startSpan(
{
name: "sharp.metadata",
op: "sharp.metadata",
attributes: {
"argos.image.path": args.filepath,
},
},
() => sharp(args.filepath).metadata(),
);
}
/**
* Resize an image to the given dimensions and write it to the output path.
*/
export async function resizeImage(args: {
inputPath: string;
outputPath: string;
width: number;
height: number;
}) {
return Sentry.st
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key