calibreapp / image-actions

A Github Action that automatically compresses JPEGs, PNGs and WebPs in Pull Requests.
https://calibreapp.com/blog/compress-images-in-prs
GNU General Public License v3.0
1.42k stars 67 forks source link

[Documentation] Broken link and missing config examples #274

Open dmyersturnbull opened 1 month ago

dmyersturnbull commented 1 month ago

Describe the bug

Hi,

The readme contains a broken link: https://github.com/calibreapp/image-actions#Configuration.

I'm also wondering if the documentation on the options/arguments could be more clear; I wasn't sure about some aspects. Apologies if I misuse any terminology!

Also, thanks for maintaining this tool for the community. I'm happy to contribute if it's useful.

Code of Conduct

benschwarz commented 1 month ago

Hey @dmyersturnbull, thanks for raising these clarifications.

I agree, the quality options could probably be better documented. Here's the TLDR version of how the quality arguments are used:

*Quality (e.g.) jpegQuality configuration is passed directly to sharp. There's also pngQuality and webpQuality

At the moment image-actions re-encodes/compresses existing images in a repository. In theory image-actions can support AVIF and HEIF resources (thanks to sharp), though it would require users to add AVIF or HEIF files to their repositories.

Personally, I have no issue in adding AVIF and HEIF as options, though haven't had much motivation to make such a change as I've not seen these compression algorithms in regular use outside CDNs.

Generally speaking, I think a better approach is to create primary image resources using well-deployed formats (e.g. webp, png. sidenote: webp are a bit of a pain without specialist tools!), then use a CDN to transcode images on the fly, based on what the end users browser supports.

@dmyersturnbull, if you've interest and time to contribute, I'd happily accept PRs to address the points you've raised in this issue. Thanks again 🥞

dmyersturnbull commented 1 month ago

@benschwarz Thanks! That's very helpful. I'll try it out and also add a clarification to the readme.

In Chrome, I'm now regularly seeing AVIF and occasionally some HEIF in the wild (presumably mostly from CDNs). I end up with AVIFs naturally as AV1 snapshots, though admittedly I have no motivation to keep those in Git :)