-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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 $image.Filter (with Grayscale , Gaussian Blur etc.) #6255
Comments
We will possibly add a |
Awesome, thank you! |
For reference, I think we could add most/all of these: "brightness_increase": gift.Brightness(30),
"brightness_decrease": gift.Brightness(-30),
"contrast_increase": gift.Contrast(30),
"contrast_decrease": gift.Contrast(-30),
"saturation_increase": gift.Saturation(50),
"saturation_decrease": gift.Saturation(-50),
"gamma_1.5": gift.Gamma(1.5),
"gamma_0.5": gift.Gamma(0.5),
"gaussian_blur": gift.GaussianBlur(1),
"unsharp_mask": gift.UnsharpMask(1, 1, 0),
"sigmoid": gift.Sigmoid(0.5, 7),
"pixelate": gift.Pixelate(5),
"colorize": gift.Colorize(240, 50, 100),
"grayscale": gift.Grayscale(),
"sepia": gift.Sepia(100),
"invert": gift.Invert(),
"mean": gift.Mean(5, true),
"median": gift.Median(5, true),
"minimum": gift.Minimum(5, true),
"maximum": gift.Maximum(5, true),
"hue_rotate": gift.Hue(45),
"color_balance": gift.ColorBalance(10, -10, -10), Which in, my head, would translate to this in Hugo templates: {{ $filters := slice ( images.GaussianBlur 1 )(images.Saturate 50) }}
{{ $blurredAndSaturated := $image.Filter $filters }} Or {{ $grayscale := $image.Filter (images.Grayscale) }} Does the above make sense? I have put the filter functions in the existing And for people who want to ask why we're not just adding these as methods on image (e.g. /cc @regisphilibert @onedrawingperday @moorereason @kaushalmodi and gang. |
@bep Looks good. Never thought that Hugo would provide image filters. 👍 |
Looks great! Want to to rely solely on Hugo for most image processing... |
They come at a fairly low implementation cost and fits nicely into what we have. Many of these are a little "special use", but I think many will find the grayscale useful to create BW blogs... and the blur filters for preview placeholders etc. |
This is great, and the template code looks clean and readable, thank you @bep! |
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
With this you can do variants of this: ``` {{ $img := resources.Get "images/misc/3-jenny.jpg" }} {{ $img := $img.Resize "300x" }} {{ $g1 := $img.Filter images.Grayscale }} {{ $g2 := $img | images.Filter (images.Saturate 30) (images.GaussianBlur 3) }} ``` Fixes gohugoio#6255
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Is is possible to have more processing methods from disintegration/imaging available to
hugo
?First one that comes to mind is Gaussian Blur:
dstImage := imaging.Blur(srcImage, 0.5)
-->{{ $image := $resource.Blur "0.5" }}
The use case is generating smooth looking placeholders for lazy loading and avoiding an extra call by inlining the
src
.Thank you!
The text was updated successfully, but these errors were encountered: