Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ ignores:
- '@babel/plugin-transform-logical-assignment-operators'
# used in image optimization script
- 'sharp'
- 'imagemin'
- 'imagemin-gifsicle'
# trezor
- 'ts-mixer'
- '@testing-library/dom'
Expand Down
Binary file modified app/images/spinner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 1 addition & 15 deletions development/optimize-media.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { writeFile, stat } from 'node:fs/promises';
import { join, resolve } from 'node:path';
import { argv, exit } from 'node:process';
import sharp from 'sharp';
import imagemin from 'imagemin';
import imageminGifsicle from 'imagemin-gifsicle';
import globby from 'globby';
import yargs from 'yargs/yargs';

Expand Down Expand Up @@ -74,18 +72,7 @@ async function optimizeImage(filePath: string, fix = true) {

if (supportedFileFormats.includes(fileInfo.format)) {
const { size: originalSize } = await stat(filePath);
let optimizedBuffer: Buffer | null = null;
if (fileInfo.format === 'gif') {
// Gifsicle is usually better at optimizing GIFs than sharp
[{ data: optimizedBuffer }] = await imagemin([filePath], {
plugins: [
imageminGifsicle({
optimizationLevel: 3,
}),
],
});
} else {
optimizedBuffer = await sharp(filePath, {
const optimizedBuffer = await sharp(filePath, {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Image Optimization Issues with Sharp

The code now uses sharp for all image optimizations, including GIFs, but applies toFormat() options like compressionLevel, effort, quality, and lossless universally. These options are not valid for all formats, particularly GIFs, which can cause runtime errors, suboptimal compression, or loss of animation quality.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to have worked for optimizing spinner.gif 🤷‍♂️

// default is `false`, which makes sharp only read the first frame of
// an animated image :facepalm:
animated: true,
Expand All @@ -98,7 +85,6 @@ async function optimizeImage(filePath: string, fix = true) {
lossless: true,
} satisfies SupportedSharpFileOptions)
.toBuffer();
}

if (optimizedBuffer.byteLength < originalSize) {
// if we saved some bytes, write the optimized image back to disk
Expand Down
2 changes: 1 addition & 1 deletion lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -5166,7 +5166,7 @@
"react-markdown>unified>bail": true,
"react-markdown>unified>extend": true,
"react-markdown>unified>is-buffer": true,
"react-markdown>unified>is-plain-obj": true,
"mocha>yargs-unparser>is-plain-obj": true,
"react-markdown>unified>trough": true,
"react-markdown>vfile": true
}
Expand Down
2 changes: 1 addition & 1 deletion lavamoat/browserify/experimental/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -5166,7 +5166,7 @@
"react-markdown>unified>bail": true,
"react-markdown>unified>extend": true,
"react-markdown>unified>is-buffer": true,
"react-markdown>unified>is-plain-obj": true,
"mocha>yargs-unparser>is-plain-obj": true,
"react-markdown>unified>trough": true,
"react-markdown>vfile": true
}
Expand Down
2 changes: 1 addition & 1 deletion lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -5166,7 +5166,7 @@
"react-markdown>unified>bail": true,
"react-markdown>unified>extend": true,
"react-markdown>unified>is-buffer": true,
"react-markdown>unified>is-plain-obj": true,
"mocha>yargs-unparser>is-plain-obj": true,
"react-markdown>unified>trough": true,
"react-markdown>vfile": true
}
Expand Down
2 changes: 1 addition & 1 deletion lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -5166,7 +5166,7 @@
"react-markdown>unified>bail": true,
"react-markdown>unified>extend": true,
"react-markdown>unified>is-buffer": true,
"react-markdown>unified>is-plain-obj": true,
"mocha>yargs-unparser>is-plain-obj": true,
"react-markdown>unified>trough": true,
"react-markdown>vfile": true
}
Expand Down
2 changes: 1 addition & 1 deletion lavamoat/build-system/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -8171,7 +8171,7 @@
"react-markdown>unified>bail": true,
"react-markdown>unified>extend": true,
"react-markdown>unified>is-buffer": true,
"react-markdown>unified>is-plain-obj": true,
"mocha>yargs-unparser>is-plain-obj": true,
"react-markdown>unified>trough": true,
"react-markdown>vfile": true
}
Expand Down
2 changes: 1 addition & 1 deletion lavamoat/webpack/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -5622,7 +5622,7 @@
"react-markdown>unified>bail": true,
"react-markdown>unified>extend": true,
"react-markdown>unified>is-buffer": true,
"react-markdown>unified>is-plain-obj": true,
"mocha>yargs-unparser>is-plain-obj": true,
"react-markdown>unified>trough": true,
"react-markdown>vfile": true
}
Expand Down
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,6 @@
"@types/gulp-sourcemaps": "^0.0.35",
"@types/he": "^1",
"@types/humanize-duration": "^3.27.4",
"@types/imagemin": "^8",
"@types/imagemin-gifsicle": "^7",
"@types/jest": "^29.5.12",
"@types/jsonwebtoken": "^9.0.10",
"@types/luxon": "^3.4.2",
Expand Down Expand Up @@ -630,8 +628,6 @@
"http-server": "^14.1.1",
"https-browserify": "^1.0.0",
"husky": "^8.0.3",
"imagemin": "^9.0.1",
"imagemin-gifsicle": "^7.0.0",
"ini": "^3.0.0",
"jest": "^29.7.0",
"jest-canvas-mock": "^2.3.1",
Expand Down Expand Up @@ -786,7 +782,6 @@
"@storybook/test-runner>@swc/core": false,
"@lavamoat/lavadome-react>@lavamoat/preinstall-always-fail": false,
"sharp": true,
"imagemin-gifsicle>gifsicle": true,
"ws>bufferutil": false,
"ws>utf-8-validate": false,
"@metamask/eth-trezor-keyring>@trezor/connect-web>@trezor/connect>@trezor/protobuf>protobufjs": false,
Expand Down
Loading
Loading