feat: add compression and resizing for image assets
Add compression and resizing to image assets. The Assets plugin now accepts two new arguments compressImages and resizeImages. The former enables compression for image assets through Sharp, an existing dependency. The second allows for global resizing of images.
The intention is to provide a mechanism with coarse options and sensible defaults, allowing Quartz sites to load faster without additional configuration.
The default value of resizeImages is 2x the default content width of 850px, ensuring that images don't lose fidelity on high DPI screens. No default maximum height is set to ensure that full-page length images (eg, infographics) are rendered as they would be in Obsidian.
built with Refined Cloudflare Pages Action
âš¡ Cloudflare Pages Deployment
| Name | Status | Preview | Last Commit |
|---|---|---|---|
| quartz | ✅ Ready (View Log) | Visit Preview | 6d8ecd33fad4c1fdf53ea02af8d64f12d43145d9 |
That's true, but that's also true for ogImages and the docs just suggests turning it off for local dev. Maybe I could add a similar note to the docs.
I suspect most folks don't manually optimize their images for the web, which makes compressImages: true a sane default. Resizing and compression is configurable and can be turned off via compressImages: false.
If this is being considered for merging I might tweak the options. Maybe it would be more clear as:
{
optimizeImages: 'off' | 'compress' | { width?: number; height?: number; fit: keyof FitEnum }
}
This will add significant build time for larger vaults.
The current PR runs single-threaded, right? This could be an area for speed-up.