Skip to content

chore: add images lint#2534

Merged
honzajavorek merged 11 commits into
masterfrom
honzajavorek/opt-images
May 15, 2026
Merged

chore: add images lint#2534
honzajavorek merged 11 commits into
masterfrom
honzajavorek/opt-images

Conversation

@honzajavorek
Copy link
Copy Markdown
Collaborator

Fix #1549

@honzajavorek honzajavorek changed the title chore: draft an image lint chore: add image lint May 14, 2026
@apify-service-account
Copy link
Copy Markdown

apify-service-account commented May 14, 2026

🗑️ Preview for this PR was deleted.

@honzajavorek honzajavorek changed the title chore: add image lint chore: add images lint May 14, 2026
@honzajavorek honzajavorek force-pushed the honzajavorek/opt-images branch from a34561c to d4951c0 Compare May 14, 2026 09:59
@honzajavorek honzajavorek marked this pull request as ready for review May 14, 2026 11:10
@honzajavorek honzajavorek requested a review from B4nan May 14, 2026 11:10
@honzajavorek honzajavorek added t-academy Issues related to Web Scraping and Apify academies. t-tooling Issues with this label are in the ownership of the tooling team. labels May 14, 2026
Comment thread package.json Outdated
Comment thread .github/workflows/test.yaml Outdated
@B4nan
Copy link
Copy Markdown
Member

B4nan commented May 14, 2026

Hmm thinking about it more, i would maybe skip this from the deps if its only supposed to be called locally. Can you run npx howfat … to see?

@honzajavorek
Copy link
Copy Markdown
Collaborator Author

@funboxteam/optimizt@5.0.2 (727 deps, 20.9mb, 5511 files, ©MIT)

Includes:

svgo@2.6.1 (18 deps, 4.32mb, 503 files, ©MIT)
guetzli@5.0.0 (320 deps, 6.07mb, 2458 files, ©undefined)
sharp@0.30.7 (47 deps, 1.67mb, 424 files, NATIVE, ©Apache-2.0)
gifsicle@7.0.1 (366 deps, 5.92mb, 2836 files, ©MIT)
gif2webp-bin@5.0.0 (297 deps, 7.68mb, 2318 files, ©MIT)
...

Seems pretty fat. I tried to find a slim alternative just for conversion to WebP, but I didn't find anything nice (gave it 5mins) which would be mantained, packaged, and published to npm. Claude suggests that sharp is the go-to library and it has a sharp-cli package, so maybe that...

At the same time, one can easily use many C programs to do that, e.g. magick input.png output.webp, cwebp input.png -o output.webp or even ffmpeg -i input.png output.webp. But that's highly platform and installation dependent. The purpose of having it in dev deps should be that people don't have to think about it and just run it.

But that's without optimization. I think, for now, we can just leave it with npx -- @funboxteam/optimizt? I think the instructions in failed linter output will be straightforward. If someone adds a page and gets the message, can just copy-paste the command and run it. And people not adding images won't need it.

When I think about it, I should also amend the message so that it warns people they'll need to update their markdown markup, too (from .png to .webp).

@B4nan
Copy link
Copy Markdown
Member

B4nan commented May 15, 2026

Ok, I'd remove it from the project deps, and suggest pnx in that message so it installs globally instead (should be the same as npx -y basically).

https://pnpm.io/cli/pnx

@honzajavorek honzajavorek force-pushed the honzajavorek/opt-images branch from 54f01a2 to 7710404 Compare May 15, 2026 11:40
Copy link
Copy Markdown
Member

@B4nan B4nan left a comment

Choose a reason for hiding this comment

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

the lockfile changes look a bit weird, are you using corepack or did you install some pnpm version manually? this usually happens when you use wrong version, corepack will resolve to the right one automatically.

otherwise looks good

@honzajavorek
Copy link
Copy Markdown
Collaborator Author

  • I found out the version of optimizt I was using was unmaintained and the new destination is @343dev/optimizt
  • Using pnx now. I had to add --config.onlyBuiltDependencies=* otherwise for the first time it asks what to build (individual libraries for image formats) and user would have to think about it and select something or all of it.
  • Because it was already too many cryptic arguments for a mere technical writer, I tried to keep it inside opt:images despite it's now pnx, and it works ✨

@honzajavorek
Copy link
Copy Markdown
Collaborator Author

Hmm since I'm not adding or removing deps now, the lockfile should stay clean. I'll just checkout it with git. I think it's a leftover after a merge conflict I had with master.

@honzajavorek honzajavorek merged commit c96af47 into master May 15, 2026
16 checks passed
@honzajavorek honzajavorek deleted the honzajavorek/opt-images branch May 15, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-academy Issues related to Web Scraping and Apify academies. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automate using webp for images to save repository size

3 participants