open-index/open-npm huggingface dataset:
npm package: @intro-to-cc/image-core
Description: Infra-agnostic image processing core for Intro to Cloud Computing exercises
Latest version: 0.1.0

# @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:

```bash
pnpm add @intro-to-cc/image-core
```

## Bytes Usage

```ts
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

```ts
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",
);
```