From e402d91ee199afcace8ae75da6c3587bb8089ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 30 Dec 2022 09:20:58 +0100 Subject: Misc doc, code refactoring to improve documentation --- resources/images/exif/exif.go | 3 +++ resources/images/image_resource.go | 10 ++++++++++ 2 files changed, 13 insertions(+) (limited to 'resources/images') diff --git a/resources/images/exif/exif.go b/resources/images/exif/exif.go index 487f250d5..8df348b23 100644 --- a/resources/images/exif/exif.go +++ b/resources/images/exif/exif.go @@ -254,8 +254,10 @@ func init() { } } +// Tags is a map of EXIF tags. type Tags map[string]any +// UnmarshalJSON is for internal use only. func (v *Tags) UnmarshalJSON(b []byte) error { vv := make(map[string]any) if err := tcodec.Unmarshal(b, &vv); err != nil { @@ -267,6 +269,7 @@ func (v *Tags) UnmarshalJSON(b []byte) error { return nil } +// MarshalJSON is for internal use only. func (v Tags) MarshalJSON() ([]byte, error) { return tcodec.Marshal(v) } diff --git a/resources/images/image_resource.go b/resources/images/image_resource.go index 4e66b010c..846959006 100644 --- a/resources/images/image_resource.go +++ b/resources/images/image_resource.go @@ -29,6 +29,7 @@ type ImageResource interface { type ImageResourceOps interface { // Height returns the height of the Image. Height() int + // Width returns the width of the Image. Width() int @@ -37,8 +38,17 @@ type ImageResourceOps interface { // Use the anchor option to change the crop box anchor point. // {{ $image := $image.Crop "600x400" }} Crop(spec string) (ImageResource, error) + + // Fill scales the image to the smallest possible size that will cover the specified dimensions in spec, + // crops the resized image to the specified dimensions using the given anchor point. + // The spec is space delimited, e.g. `200x300 TopLeft`. Fill(spec string) (ImageResource, error) + + // Fit scales down the image using the given spec. Fit(spec string) (ImageResource, error) + + // Resize resizes the image to the given spec. If one of width or height is 0, the image aspect + // ratio is preserved. Resize(spec string) (ImageResource, error) // Filter applies one or more filters to an Image. -- cgit v1.2.3