summaryrefslogtreecommitdiffstats
path: root/resources/images
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-12-30 09:20:58 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-01-04 18:01:26 +0100
commite402d91ee199afcace8ae75da6c3587bb8089ace (patch)
treea0f51de9707ed03aa1a3d7a9195fd9d0fceab108 /resources/images
parent3c51625c7152abca7e035fae15fc6807ca21cc86 (diff)
Misc doc, code refactoring to improve documentation
Diffstat (limited to 'resources/images')
-rw-r--r--resources/images/exif/exif.go3
-rw-r--r--resources/images/image_resource.go10
2 files changed, 13 insertions, 0 deletions
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.