From b198ea2ecc6eeafa5e70a7394a2139ea3f6fb9b6 Mon Sep 17 00:00:00 2001 From: Tomas Aparicio Date: Sat, 30 Jan 2016 16:27:27 +0000 Subject: [PATCH 1/3] fix(rotate): pre-rotate image based on EXIT orientation --- resize.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/resize.go b/resize.go index 563a787..984d1b1 100644 --- a/resize.go +++ b/resize.go @@ -32,6 +32,14 @@ func Resize(buf []byte, o Options) ([]byte, error) { debug("Options: %#v", o) + // Initial image auto rotate / flip for proper transformation calculus + if o.Rotate == 0 { + image, err = rotateAndFlipImage(image, o) + if err != nil { + return nil, err + } + } + inWidth := int(image.Xsize) inHeight := int(image.Ysize) @@ -74,12 +82,6 @@ func Resize(buf []byte, o Options) ([]byte, error) { return nil, err } - // Rotate / flip image, if necessary - image, err = rotateAndFlipImage(image, o) - if err != nil { - return nil, err - } - // Transform image, if necessary if shouldTransformImage(o, inWidth, inHeight) { image, err = transformImage(image, o, shrink, residual) @@ -102,6 +104,12 @@ func Resize(buf []byte, o Options) ([]byte, error) { return nil, err } + // Transform to original rotation, if necessary + image, err = rotateAndFlipImage(image, o) + if err != nil { + return nil, err + } + // Flatten image on a background, if necessary image, err = imageFlatten(image, imageType, o) if err != nil { @@ -149,7 +157,7 @@ func shouldTransformImage(o Options, inWidth, inHeight int) bool { } func shouldApplyEffects(o Options) bool { - return o.GaussianBlur.Sigma > 0 || o.GaussianBlur.MinAmpl > 0 || o.Sharpen.Radius > 0 && o.Sharpen.Y2 > 0 || o.Sharpen.Y3 > 0 + return o.GaussianBlur.Sigma > 0 || o.GaussianBlur.MinAmpl > 0 || o.Sharpen.Radius > 0 && o.Sharpen.Y2 > 0 || o.Sharpen.Y3 > 0 } func transformImage(image *C.VipsImage, o Options, shrink int, residual float64) (*C.VipsImage, error) { From 50b525b517e8852910ba1563139b9dcf1ea79f08 Mon Sep 17 00:00:00 2001 From: Tomas Aparicio Date: Sat, 30 Jan 2016 16:28:47 +0000 Subject: [PATCH 2/3] feat(version): bump --- version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.go b/version.go index 7372907..e722bd4 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package bimg -const Version = "0.1.21" +const Version = "0.1.22" From a7706b6033449b112be5b1a46f1d95b145c16d2e Mon Sep 17 00:00:00 2001 From: Tomas Aparicio Date: Sat, 30 Jan 2016 16:34:24 +0000 Subject: [PATCH 3/3] feat(travis): add GO 1.5 --- .travis.yml | 1 + vips.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index aa82785..7bd7e9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: go go: + - 1.5 - 1.4 - 1.3 - release diff --git a/vips.go b/vips.go index a2555d4..989b864 100644 --- a/vips.go +++ b/vips.go @@ -65,7 +65,7 @@ func init() { } // Explicit thread-safe start of libvips. -// Only call this function if you've previously shutdown libvips +// Only call this function if you previously shutdown libvips func Initialize() { if C.VIPS_MAJOR_VERSION <= 7 && C.VIPS_MINOR_VERSION < 40 { panic("unsupported libvips version!")