パッケージ公開に最適化

This commit is contained in:
tamaina
2023-02-05 12:34:04 +00:00
parent c6b14befe9
commit 85a7f47539
24 changed files with 737 additions and 60 deletions

View File

@ -1 +1,26 @@
import sharp from"sharp";export const webpDefault={quality:85,alphaQuality:95,lossless:false,nearLossless:false,smartSubsample:true,mixed:true};export function convertToWebpStream(path,width,height,options=webpDefault){return convertSharpToWebpStream(sharp(path),width,height,options)}export function convertSharpToWebpStream(sharp,width,height,options=webpDefault){const data=sharp.resize(width,height,{fit:"inside",withoutEnlargement:true}).rotate().webp(options);return{data,ext:"webp",type:"image/webp"}}
import sharp from 'sharp';
export const webpDefault = {
quality: 85,
alphaQuality: 95,
lossless: false,
nearLossless: false,
smartSubsample: true,
mixed: true,
};
export function convertToWebpStream(path, width, height, options = webpDefault) {
return convertSharpToWebpStream(sharp(path), width, height, options);
}
export function convertSharpToWebpStream(sharp, width, height, options = webpDefault) {
const data = sharp
.resize(width, height, {
fit: 'inside',
withoutEnlargement: true,
})
.rotate()
.webp(options);
return {
data,
ext: 'webp',
type: 'image/webp',
};
}