docs/content/en/methods/resource/Fit.md
{{% include "/_common/methods/resource/global-page-remote-resources.md" %}}
The Fit method returns a new resource from a processable image according to the given processing specification.
[!note] Use the
reflect.IsImageResourceProcessablefunction to verify that an image can be processed.
When fitting, you must provide both width and height (such as 300x175) within the specification. Fit maintains the original aspect ratio by downscaling the image until it fits within the specified dimensions. Unlike Fill or Resize, this method will never upscale an image; if the source image is smaller than the target dimensions, the dimensions of the resulting image are the same as the original.
{{ with resources.Get "images/original.jpg" }}
{{ with .Fit "300x175" }}
{{ end }}
{{ end }}
In the example above, "300x175" is the processing specification.
{{% include "/_common/methods/resource/processing-spec.md" %}}
{{ with resources.Get "images/original.jpg" }}
{{ with .Fit "300x175" }}
{{ end }}
{{ end }}
{{< img src="images/examples/zion-national-park.jpg" alt="Zion National Park" filter="Process" filterArgs="fit 300x175" example=true
}}