-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add webp and avif conversion to strapi-plugin-upload #47
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the intention.
I'm wondering if we should allow some more configurations for this. Let's say you want to only convert png to webp and not jpg for some reason 🤔
Something that I see might be a request would be to make this dynamic so you can decide at runtime which conversions to run. Would be nice to think about that in the rfc
export default ({ env }) => ({ | ||
upload: { | ||
config: { | ||
convertAllImagesTo: 'webp' | 'avif'; // To be defined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have some resource one which conversions are supported to webp? is it jpg/png to webp or are there more formats supported?
How does sharp handle non compatible formats ? is it just not doing the transform or throws ? if so we would need to have a mapping to maintain?
From the documentation (https://sharp.pixelplumbing.com/#formats):
From my small non exhaustive testing:
Important note: Converting a large
You are dealing with a noob here 😅, I didn’t get what you mean
I guess, technically nothing is stopping it. I would double check security-wise if it is safe (I don’t know much about security, but it looks like vulnerabilities could get through)
At a first look, this could also be done.
|
Personal opinion and motivations
I see this feature for people that don't want to think about images instead of people who want more granular control. A more "batteries included" approach. Very opinionated, but is most likely the best option for you. Question:
|
This would be valid then also for other image formats, right? So e.g. transforming an uploaded PNG into an JPG and WebP, or transforming an uploaded WebP into an AVIV (just a made up example). While I do not really see a use case...what do you think about a configurable array here? I would suggest something like:
Looking at the current configuration mechanism of the upload plugin (being statically configured in the |
I didn't have time to work on this, but the main blocker right now is whether it is a good idea to change the format altogether. What I mean by that is that these algorithms are clearly good when you go from a raw or uncompressed image to a compressed image. But when you are dealing with already compressed images, things can go wrong. I did some testing with And when converting So basically just transforming all images to I did very little test and research, and I know very little about image compression, so take this very lightly. Current hypothesis:
If I'm totally honest, we lost interest in building this because now we are converting all images to Pin me if you still want me to work on it. |
This pull request has been mentioned on Strapi Community Forum. There might be relevant details there: https://forum.strapi.io/t/image-file-format-webm-not-allowed-in-media-library-upload/34346/2 |
Hello, Do you have any news on this development allowing Strapi to directly convert jpg/jpeg/png This essential feature is sorely lacking in 2024... |
Link to markdown: https://github.com/Antoine-lb/rfcs/blob/main/rfcs/xxxx-template.md