Spaces:
Sleeping
Sleeping
File size: 614 Bytes
3530df7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import JPEG from "jpeg-js";
import { Format } from "@jimp/types";
export interface JPEGOptions {
quality?: number;
}
export interface DecodeJpegOptions {
useTArray?: false;
colorTransform?: boolean;
formatAsRGBA?: boolean;
tolerantDecoding?: boolean;
maxResolutionInMP?: number;
maxMemoryUsageInMB?: number;
}
export default function jpeg() {
return {
mime: "image/jpeg",
encode: (bitmap, { quality = 100 }: JPEGOptions = {}) =>
JPEG.encode(bitmap, quality).data,
decode: (data, options?: DecodeJpegOptions) => JPEG.decode(data, options),
} satisfies Format<"image/jpeg">;
}
|