mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
22 lines
444 B
TypeScript
22 lines
444 B
TypeScript
import type { FlipOptions, Sharp } from "../types.js";
|
|
|
|
export async function flip(image: Sharp, options: FlipOptions): Promise<Sharp> {
|
|
const { horizontal, vertical } = options;
|
|
|
|
if (!horizontal && !vertical) {
|
|
throw new Error("Flip requires at least one of horizontal or vertical");
|
|
}
|
|
|
|
let result = image;
|
|
|
|
if (horizontal) {
|
|
result = result.flop();
|
|
}
|
|
|
|
if (vertical) {
|
|
result = result.flip();
|
|
}
|
|
|
|
return result;
|
|
}
|