icns

Easily create .icns files (Mac Icons) with this Go library or the included CLI.
Log | Files | Refs | LICENSE

commit 894342c969f7e8875c2bd3166ef847fc3e9b536a
parent 6d0a0b12337608fa50de5637322d15704e781e9c
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date:   Sat, 10 Feb 2018 17:51:48 +0100

[*] Moved `EncodeWithInterpolationFunction` closer to its usage.

Diffstat:
Micns.go | 24++++++++++++++++++++++++
Minterpolation.go | 27---------------------------
2 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/icns.go b/icns.go @@ -1,6 +1,7 @@ package icns import ( + "errors" "image" "io" @@ -15,6 +16,29 @@ func Encode(wr io.Writer, img image.Image) error { return EncodeWithInterpolationFunction(wr, img, NearestNeighbor) } +// EncodeWithInterpolationFunction uses the given interpolation function resize +// the image before writing out to wr. +func EncodeWithInterpolationFunction( + wr io.Writer, + img image.Image, + interp InterpolationFunction, +) error { + if wr == nil { + return errors.New("cannot write to nil writer") + } + if img == nil { + return errors.New("cannot process nil image") + } + iconset, err := NewIconSet(img, interp) + if err != nil { + return err + } + if _, err := iconset.WriteTo(wr); err != nil { + return err + } + return nil +} + // NewIconSet uses the source image to create an IconSet. // If width != height, the image will be resized using the largest side without // preserving the aspect ratio. diff --git a/interpolation.go b/interpolation.go @@ -1,10 +1,6 @@ package icns import ( - "errors" - "image" - "io" - "github.com/nfnt/resize" ) @@ -26,26 +22,3 @@ const ( // Lanczos interpolation (a=3) Lanczos3 ) - -// EncodeWithInterpolationFunction uses the given interpolation function resize -// the image before writing out to wr. -func EncodeWithInterpolationFunction( - wr io.Writer, - img image.Image, - interp InterpolationFunction, -) error { - if wr == nil { - return errors.New("cannot write to nil writer") - } - if img == nil { - return errors.New("cannot process nil image") - } - iconset, err := NewIconSet(img, interp) - if err != nil { - return err - } - if _, err := iconset.WriteTo(wr); err != nil { - return err - } - return nil -}