Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files: Thumb not working with WEBP format #825

Open
Siumauricio opened this issue Oct 23, 2022 · 7 comments
Open

Files: Thumb not working with WEBP format #825

Siumauricio opened this issue Oct 23, 2022 · 7 comments

Comments

@Siumauricio
Copy link

Hi, I was testing to upload and resize WEBP images with the thumb property, the file upload is working fine, but the resize is not working I was checking the code probably this is the issue, it's just taking these formats and not WEBP.

var imageContentTypes = []string{"image/png", "image/jpg", "image/jpeg"}

if list.ExistInSlice(oAttrs.ContentType, imageContentTypes) {

@Siumauricio Siumauricio changed the title Thumb not working with WEBP format Files: Thumb not working with WEBP format Oct 23, 2022
@ganigeorgiev
Copy link
Member

Unfortunately It's not just the file extension that is missing.

Webp is not supported at the moment because the image library that we use, disintegration/imaging, doesn't support webp (mostly due to the lack of native go webp encoding - golang/go#45121; most webp go packages seems to rely on libwebp which requires cgo and I want to avoid that).

There are workarounds, like decoding the uploaded image and converting it to jpg/png thumb, but for now this remains out of the scope for v1.0.

@KnockOutEZ
Copy link

@ganigeorgiev can I look into this and try to solve this without cgo?

@ganigeorgiev
Copy link
Member

@KnockOutEZ I'm open for suggestions but please first outline some of your planned implementation details to avoid investing unnecessary time and efforts in something that may not get merged.

@Wikidepia
Copy link

Wikidepia commented Jan 8, 2024

I stumbled upon this issue, just want to add that there are CGo-free webp encoder/decoder: https://git.sr.ht/~jackmordaunt/go-libwebp :)

@laszlo1337

This comment was marked as off-topic.

@ganigeorgiev

This comment was marked as off-topic.

@aalokkamble
Copy link

@ganigeorgiev, I have a suggestion regarding adding WebP support. We can still utilize the disintegration/imaging, library, but with a slight adjustment. We can incorporate another library to convert WebP images to JPEG format, then proceed with imaging to generate thumbnail blobs. Subsequently, we can use this webp library to convert the thumbnail blobs back to WebP format and save them.

If you're okay with this approach, I'm ready to dive into the coding process!

@ganigeorgiev
Copy link
Member

@aalokkamble Feel free to create a POC implementation but I'm not interested on working on this for the moment.
Note that your custom implementation doesn't necessary need to be part of the core repo and can be implemented to some extend as a "plugin"/library by attaching to the OnFileDownloadRequest hook (see example "plugins" in https://github.com/pocketbase/pocketbase/tree/master/plugins).

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

No branches or pull requests

6 participants