Skip to content

Commit

Permalink
Update doc string for ImageCommandResult, and add Example usage of Co…
Browse files Browse the repository at this point in the history
…nvertImageCommand (refs #220)
  • Loading branch information
justinfx committed Jan 1, 2020
1 parent 26d2f60 commit d4bb98c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
11 changes: 4 additions & 7 deletions imagick/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions imagick/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package imagick

import (
"fmt"
"io/ioutil"
"os"
"testing"
Expand All @@ -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 {
Expand Down

0 comments on commit d4bb98c

Please sign in to comment.