@intro-to-cc/image-core
v0.1.0
Published
Infra-agnostic image processing core for Intro to Cloud Computing exercises
Downloads
57
Readme
@intro-to-cc/image-core
Infra-agnostic image processing core for exercise solutions.
Prerequisites
- Node.js 24
- pnpm
Features
- Validate image payloads
- Resize by longest edge
- Convert format (jpeg/png/webp)
- Return required metadata
- Bytes and stream entry points
API Surface
This package intentionally exposes a small student-facing API:
| Function | Input style | Typical use case |
| -------------------- | ----------------- | -------------------------------------------------- |
| processImageBytes | Buffer | Use when you already have complete bytes in memory |
| processImageStream | Readable stream | Use when image data comes from stream-based IO |
Persistence and storage integration stay in your app code.
Install
Published package:
pnpm add @intro-to-cc/image-coreBytes Usage
import { processImageBytes } from "@intro-to-cc/image-core";
const result = await processImageBytes(
inputBuffer,
{
maxLongEdgePx: 1280,
outputFormat: "jpeg",
outputQuality: 85,
},
"img-1",
);
console.log(result.metadata, result.contentType);Stream Usage
import { processImageStream } from "@intro-to-cc/image-core";
import { Readable } from "node:stream";
const sourceStream: Readable = getReadableFromSomewhere();
const result = await processImageStream(
sourceStream,
{
maxLongEdgePx: 1280,
outputFormat: "jpeg",
outputQuality: 85,
},
"img-2",
"processed/img-2.jpg",
);