#11151·hugo

Add minScale to image config

Author: nibeCreated Jun 22, 2023Updated Sep 28, 2026
LabelsEnhancementUpstreamKeep

$image.Fill with the default smart cropping unnecessarily crops images. Example:

xml
{{ with .Resources.GetMatch "example.jpg" }}<!-- 300x200 px -->
  {{ $smart := .Fill "150x100" }}<!-- Same aspect ratio, no need to crop! -->
  {{ $expected := .Fill "150x100 Center" }}
  <img src="{{ .RelPermalink }}">
  <img src="{{ $smart.RelPermalink }}">
  <img src="{{ $expected.RelPermalink }}">
{{ end }}

example.jpg: example Smart crop (feathers chopped off, unnecessary because same aspect ratio): smart-crop Expected: expected

This does not just apply when the aspect ratio is the same, it unnecessarily crops whenever it feels like it. I would rather not use another anchor because smart cropping would be super useful if it only cropped when necessary. I filed this as a bug rather than a feature request because it is the default behavior and unexpected (for me).

smartcrop.js (which the smartcrop library used in Hugo is based on) has the following option, which appears to prevent this issue: minScale: minimal scale of the crop rect, set to 1.0 to prevent smaller than necessary crops (lowers the risk of chopping things off).

What version of Hugo are you using (hugo version)?


$ hugo version
hugo v0.114.0+extended darwin/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes.