Generate webp thumbnails by KevSlashNull · Pull Request #6744 · pocketbase/pocketbase · GitHub
Skip to content

Generate webp thumbnails - #6744

Merged
ganigeorgiev merged 1 commit into
pocketbase:masterfrom
KevSlashNull:webp-thumbs
Apr 20, 2025
Merged

ganigeorgiev merged 1 commit into
pocketbase:masterfrom
KevSlashNull:webp-thumbs

Conversation

@KevSlashNull

Copy link
Copy Markdown
Contributor

This adds support for webp thumbnails by explicitly importing the
official (but experimental) x/image/webp decoder for webp.

Unless the decoder panics (can it?), this is safe. Pocketbase will fall
back to reusing the fullsize image if creating a thumbnail fails. Which
is already the current behavior for all webp images.

Since disintegration/imaging is not aware of webp, webp thumbnails will
be generated in png format. This is a caveat but modern web browsers
generally don’t rely on file extensions to detect image formats.

This adds support for webp thumbnails by explicitly importing the
official (but experimental) x/image/webp decoder for webp.

Unless the decoder panics (can it?), this is safe. Pocketbase will fall
back to reusing the fullsize image if creating a thumbnail fails. Which
is already the current behavior for all webp images.

Since disintegration/imaging is not aware of webp, webp thumbnails will
be generated in png format. This is a caveat but modern web browsers
generally don’t rely on file extensions to detect image formats.
@KevSlashNull

Copy link
Copy Markdown
Contributor Author

@ganigeorgiev

Copy link
Copy Markdown
Member

I'm not really sure. As mentioned in the linked comment, I wanted to avoid the workaround of converting them to jpg/png but since webp thumbs seems to be a common request I guess it could be better than nothing. I'll have to think a little more on it.

@ganigeorgiev

Copy link
Copy Markdown
Member

In the end it is better than nothing, so let's merge it. If it ended up causing issues we can always revert it.

I'll update also the tests to add a mimetype thumb check to ensure that the fallback png is properly generated.

@ganigeorgiev
ganigeorgiev merged commit 5d46fb0 into pocketbase:master Apr 20, 2025
warpbuild-benchmark-bot Bot added a commit to WarpBuilds/pocketbase that referenced this pull request Apr 20, 2025
@qoheleth-tech

qoheleth-tech commented Dec 24, 2025 •

Copy link
Copy Markdown

webp thumbnails will be generated in png format

Does this mean that the thumbnail will be a webp file but have a png extension; or that the thumbnail will be a png with a png extension; or that the thumbnail will keep the webp extension but actually be a png image? Thanks for your work on this!

@ganigeorgiev

ganigeorgiev commented Dec 24, 2025 •

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants