mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
16 lines
370 B
TypeScript
16 lines
370 B
TypeScript
import type { RotateOptions, Sharp } from "../types.js";
|
|
|
|
export async function rotate(image: Sharp, options: RotateOptions): Promise<Sharp> {
|
|
const { angle, background } = options;
|
|
|
|
const isMultipleOf90 = angle % 90 === 0;
|
|
|
|
if (isMultipleOf90) {
|
|
return image.rotate(angle);
|
|
}
|
|
|
|
return image.rotate(angle, {
|
|
background: background ?? "#000000",
|
|
});
|
|
}
|