Support browser image transformations#7845
Conversation
f1a29e3 to
366ec3e
Compare
|
@evan6seven this would be a great feature in Decap CMS, but before we merge it, we need to agree on what it would look like. Did you see issue #7107? There was a lot of debate around how to do it. I think it addresses a similar question, but in much more detail. You added the Photon dependency, which could be a good fit, but I have some concerns. Most notably, it's maintained by a single person. The history is not in favor of the longevity of such libraries, so we have to be really cautious before we use it. |
|
Thanks, I had not seen that issue discussion. I will read it and incorporate decisions from there. |
f17f28e to
95ec682
Compare
yanthomasdev
left a comment
There was a problem hiding this comment.
Amazing work @evan6seven, I see your PR is a draft so I'm leaving just a few initial comments/suggestions for you to consider
|
Having looked at the original issue thread what I took away was:
I'm minimizing libraries by using Canvas for jpeg and png images. @yanthomasdev thanks for the feedback, I've updated based on it. |
|
Great work @evan6seven, I believe this should be good to go. I added the missing |
Yeah, looks good |
|
Edit: nevermind I was wrong about the bug. Ignore. Original comment:
|
yanthomasdev
left a comment
There was a problem hiding this comment.
LGTM! Good work! Could you also make a PR in the decap-website repo adding the necessary docs for this feature? Thanks.
Sure, I made one: decaporg/decap-website#167 |
From Issue #7107
Summary
Adds browser-side media processing for image uploads. Projects can process an uploaded image once before it is persisted by the normal media upload flow, with support for resizing, aspect-ratio cropping, metadata stripping through re-encoding, and optional JPEG/WebP conversion.
Configuration
Notes on the config:
media_processingcan be set globally or on an individual image/file field; field config overrides the global config.format.enabled: trueconverts the upload tojpegorwebp.format.enabled: falsekeeps the uploaded image's original supported type (jpeg,png, orwebp) while still allowing resize/crop/re-encode processing.qualityis a plain number from1to100; there is noautoquality mode.aspect_ratioaccepts values like16_916:916x9.Conversion methods
toBlobwith the configured quality.@jsquash/webp, so WebP compression works in browsers that cannot encode WebP through Canvas, including Safari.@jsquash/webpare emitted through the webpack WASM asset rule.What changed
media_processingconfig schema and TypeScript declarations.