From d4bb98c8ea0aa2390b51ef754be2eaf8276126d5 Mon Sep 17 00:00:00 2001 From: Justin Israel Date: Wed, 1 Jan 2020 17:29:05 +1300 Subject: [PATCH] Update doc string for ImageCommandResult, and add Example usage of ConvertImageCommand (refs #220) --- imagick/image.go | 11 ++++------- imagick/image_test.go | 11 +++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/imagick/image.go b/imagick/image.go index c00c30d..0231565 100644 --- a/imagick/image.go +++ b/imagick/image.go @@ -38,6 +38,9 @@ func NewMagickImage(info *ImageInfo, width, height uint, return &Image{img: img}, nil } +// ImageCommandResult is returned by a call to +// ConvertImageCommand. It contains the ImageInfo +// and Metadata string generated by the convert command. type ImageCommandResult struct { Info *ImageInfo Meta string @@ -47,13 +50,7 @@ type ImageCommandResult struct { ConvertImageCommand reads one or more images, applies one or more image processing operations, and writes out the image in the same or differing format. - -A description of each parameter follows: - * image_info: the image info. - * argc: the number of elements in the argument vector. - * argv: A text array containing the command line arguments. - * metadata: any metadata is returned here. - * exception: return any errors or warnings in this structure. +The first item in the args list is expected to be the program name, ie "convert". */ func ConvertImageCommand(args []string) (*ImageCommandResult, error) { size := len(args) diff --git a/imagick/image_test.go b/imagick/image_test.go index 6399a2a..0c3d71a 100644 --- a/imagick/image_test.go +++ b/imagick/image_test.go @@ -5,6 +5,7 @@ package imagick import ( + "fmt" "io/ioutil" "os" "testing" @@ -31,6 +32,16 @@ func TestNewMagickImage(t *testing.T) { } } +func ExampleConvertImageCommand() { + ret, err := ConvertImageCommand([]string{ + "convert", "logo:", "-resize", "100x100", "/tmp/out.png", + }) + if err != nil { + panic(err) + } + fmt.Println("Meta:", ret.Meta) +} + func TestConvertImageCommand(t *testing.T) { tmp, err := ioutil.TempFile("", "imagick_test") if err != nil {