How to use Hugo's image processing to only change quality

I have a render hook that I use to resize images that are larger than a certain width. And for the images that are smaller than that width I don’t want to resize but do want to change their JPEG quality. I was trying the code below but it complains that I need to provide width and height.

{{ $smallImage := $image.Resize "q90" }}

Can I pass $image.Width to this Resize function? Im very new to Go so please excuse me.

You should be able to do something like

{{ $w := $image.Width }}
{{ $xw := print "x" $w }}

{{ $small := $image.Resize $xw "q90" }}

Thank you. It gave the following error but I made some changes and got it to work! Thanks again!

at <$image.Resize>: wrong number of args for Resize: want 1 got 2


{{ $w := $image.Width }}
{{ $wx90 := print $w "x q90" }}

{{ $small := $image.Resize $wx90 }}
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.