-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Description
Given:
{{ $img := $original.Resize "400x300 q55" }}
{{ $img = $img | images.Filter (images.GaussianBlur 6) (images.Pixelate 8) }}
There are currently some problems with the above:
- The image gets encoded twice
- There is no way to control the encoding (e.g. quality) for the second operation.
- If you want the end result encode to different formats, you need to repeat the image processing for each target format (e.g. JPEG and WEBP)
I suggest that we
- add a target options argument to
images.Filter
which can be a string (e.g.webp
) or a map (which also allows setting quality settings) - Export the resize functions (Resize, Fill, Fit) as filters.
This way you can do:
{{ $img = $img | images.Filter (images.Resize 400 300) (images.GaussianBlur 6) (images.Pixelate 8) (images.EncodeTo "webp") }}
I'm tempted to also use the same images.Filter
to return a slice if multiple images.EncodeTo
arguments is passed, e.g.:
{{ $imgages := $img | images.Filter (images.Resize 400 300) (images.GaussianBlur 6) (images.Pixelate 8) (images.EncodeTo "webp") (images.EncodeTo "jpeg") }}
But it's probably best to just add a new function, e.g.:
{{ $imgages := $img | images.FilterAll (images.Resize 400 300) (images.GaussianBlur 6) (images.Pixelate 8) (images.EncodeTo "webp") (images.EncodeTo "jpeg") }}
Feedback welcome, @jmooring @moorereason @onedrawingperday and gang.
onedrawingperday, torrayne, cmlnet and pluser