Skip to content

Commit

Permalink
chore(webp): do not heavily compress main image
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSolati committed Feb 14, 2022
1 parent 485256b commit cc69531
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tools/webp.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const path = require('path');
const sharp = require('sharp');
const webpConverter = require('webp-converter');

const quality = 30;
const srcsetWidths = [240, 360, 480, 720, 1080];
const srcsetWidths = [240, 360, 480, 720];
const tempDirectory = tmpdir();

// Create width folders if they don't exist
Expand Down Expand Up @@ -60,7 +59,7 @@ const createSrcSet = async webp => {
for (const size of srcsetData) {
const sizePath = path.join(__dirname, '../', 'src', size.src);
await sharp(createOutputPath(webp))
.webp({quality})
.webp({quality: 30})
.resize(size.width)
.toFile(sizePath);
}
Expand All @@ -78,7 +77,7 @@ const createWebp = async (downloadedImage, webp) => {
const outputPath = createOutputPath(webp);
const isGif = path.extname(downloadedImage).toLowerCase() === '.gif';
const webpFunction = isGif ? webpConverter.gwebp : webpConverter.cwebp;
await webpFunction(downloadedImage, outputPath, `-q ${quality}`);
await webpFunction(downloadedImage, outputPath, `-q 80`);
};

/**
Expand Down

0 comments on commit cc69531

Please sign in to comment.