Skip to content

Commit

Permalink
fix webp compression
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodBoyDigital committed Apr 22, 2024
1 parent d212bd6 commit 26a54cf
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions packages/mipmap-compress/src/utils/compressSharp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { AvifOptions, WebpOptions, JpegOptions, PngOptions } from 'sharp';
import type { MipmapCompressImageData, CompressOptions } from '../mipmapCompress';
import sharp from 'sharp';

export async function compressSharp(
image: MipmapCompressImageData,
Expand All @@ -9,14 +8,10 @@ export async function compressSharp(
{
const compressed: MipmapCompressImageData[] = [];

let sharpImage = image.sharpImage;
const sharpImage = image.sharpImage;

if (image.format === '.png' && options.png)
{
// optimising the PNG image and using that as the source of the WebP and AVIF images
// will result in a smaller file size and increase the speed of the compression.
sharpImage = sharp(await image.sharpImage.png({ ...options.png as PngOptions, force: true }).toBuffer());

compressed.push({
format: '.png',
resolution: image.resolution,
Expand Down

0 comments on commit 26a54cf

Please sign in to comment.