Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import sharp from "sharp";
|
||||
/**
|
||||
* Convert to WebP
|
||||
* with resize, remove metadata, resolve orientation, stop animation
|
||||
*/ export async function convertToWebp(path, width, height, quality = 85) {
|
||||
return convertSharpToWebp(await sharp(path), width, height, quality);
|
||||
}
|
||||
export async function convertSharpToWebp(sharp1, width, height, quality = 85) {
|
||||
const data = await sharp1.resize(width, height, {
|
||||
fit: "inside",
|
||||
withoutEnlargement: true
|
||||
}).rotate().webp({
|
||||
quality
|
||||
}).toBuffer();
|
||||
return {
|
||||
data,
|
||||
ext: "webp",
|
||||
type: "image/webp"
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user