[Feature Request] Support multiple image formats for serving #2201

Open
opened 2026-10-05 01:09:35 +02:00 by adam · 0 comments
Owner

I would like to be able to select a serving image format the same way I select serving image sizes.

There are already a few FRs and forum threads around support for webp/HEIC/AVIV/jpeg XL/..., but the overall conclusion seems to be that jpg works well enough. E.g this comment from @plegall :

As far as I see it, JPEG is not that bad of a deal. We may find better in terms of filesize with the same quality, but would we have the same support by web browsers?

But there can be more than one! It'd be great if I could choose which one(s) I want, just like I get to pick image sizes, e.g.:

Multiple Size: [x]Square [x]Thumbnail [ ] ...
Serving Formats: [x]JPG [x]webp [ ] ...

For file types with less-than-universal support, some logic based on Accept header could then pick the right one if multiple exist.


Something approaching this can already be done by manually generating other formats, e.g.

for img in *jpg; do cwebp -q 80 "$img" -o "${img%jpg}webp"; done

and some RewriteRule trickery

 <Directory /var/www/piwigo/>
  RewriteBase "/gallery/"
  RewriteEngine On
  RewriteCond %{HTTP_ACCEPT} image/webp
  RewriteCond /var/www/piwigo/$1.webp -f
  RewriteRule (.+)\.jpe?g$ $1\.webp [NC,T=image/webp]
  ...

But this requires some faffing, and also results in cwebp re-converting/compressing the already-resized/compressed images, so it's not ideal for compression or image quality. A more-than-one-liner could figure out the correct source file and target resolution, but at that point I'd just be recreating logic that already exists in piwigo...

I would like to be able to select a serving image format the same way I select serving image sizes. There are already a few FRs and forum threads around support for webp/HEIC/AVIV/jpeg XL/..., but the overall conclusion seems to be that jpg works well enough. E.g [this comment](https://github.com/Piwigo/Piwigo/issues/1144#issuecomment-1684202302) from @plegall : > As far as I see it, JPEG is not that bad of a deal. We may find better in terms of filesize with the same quality, but would we have the same support by web browsers? But there can be more than one! It'd be great if I could choose which one(s) I want, just like I get to pick image sizes, e.g.: Multiple Size: [x]Square [x]Thumbnail [ ] ... Serving Formats: [x]JPG [x]webp [ ] ... For file types with less-than-universal support, some logic based on Accept header could then pick the right one if multiple exist. --- Something approaching this can already be done by manually generating other formats, e.g. for img in *jpg; do cwebp -q 80 "$img" -o "${img%jpg}webp"; done and some `RewriteRule` trickery <Directory /var/www/piwigo/> RewriteBase "/gallery/" RewriteEngine On RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond /var/www/piwigo/$1.webp -f RewriteRule (.+)\.jpe?g$ $1\.webp [NC,T=image/webp] ... But this requires some faffing, and also results in cwebp re-converting/compressing the already-resized/compressed images, so it's not ideal for compression or image quality. A more-than-one-liner could figure out the correct source file and target resolution, but at that point I'd just be recreating logic that already exists in piwigo... <!-- github-sync-id:4041335641 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#2201