Usage
The core package exposes an asynchronous function executePipeline()
that lets you process a
given pipeline schema on an image buffer. It returns an array of saved formats.
- JavaScript
- TypeScript
function.js
import { executePipeline } from "@ipp/core";
async function processImage(job) {
const pipeline = [{
pipe: "resize",
options: {
resizeOptions: {
width: 1280
}
}
}];
const source = await downloadFromBucket(job);
const result = await executePipeline(pipeline, source);
await uploadToBucket(job, result.formats[0].data.buffer);
}
function.ts
import { executePipeline } from "@ipp/core";
import { Metadata, Pipeline } fro "@ipp/common";
async function processImage(job: Job) {
const pipeline: Pipeline = [{
pipe: "resize",
options: {
resizeOptions: {
width: 1280
}
}
}];
const source: Buffer = await downloadFromBucket(job);
const result = await executePipeline(pipeline, source);
await uploadToBucket(job, result.formats[0].data.buffer);
}