mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-16 02:45:54 -07:00
Merge pull request #76 from h2non/develop
fix(rotate): pre-rotate image based on EXIF orientation
This commit is contained in:
commit
61c9747f82
4 changed files with 18 additions and 9 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
|
- 1.5
|
||||||
- 1.4
|
- 1.4
|
||||||
- 1.3
|
- 1.3
|
||||||
- release
|
- release
|
||||||
|
|
|
||||||
20
resize.go
20
resize.go
|
|
@ -32,6 +32,14 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
||||||
|
|
||||||
debug("Options: %#v", o)
|
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)
|
inWidth := int(image.Xsize)
|
||||||
inHeight := int(image.Ysize)
|
inHeight := int(image.Ysize)
|
||||||
|
|
||||||
|
|
@ -74,12 +82,6 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rotate / flip image, if necessary
|
|
||||||
image, err = rotateAndFlipImage(image, o)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transform image, if necessary
|
// Transform image, if necessary
|
||||||
if shouldTransformImage(o, inWidth, inHeight) {
|
if shouldTransformImage(o, inWidth, inHeight) {
|
||||||
image, err = transformImage(image, o, shrink, residual)
|
image, err = transformImage(image, o, shrink, residual)
|
||||||
|
|
@ -102,6 +104,12 @@ func Resize(buf []byte, o Options) ([]byte, error) {
|
||||||
return nil, err
|
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
|
// Flatten image on a background, if necessary
|
||||||
image, err = imageFlatten(image, imageType, o)
|
image, err = imageFlatten(image, imageType, o)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
package bimg
|
package bimg
|
||||||
|
|
||||||
const Version = "0.1.21"
|
const Version = "0.1.22"
|
||||||
|
|
|
||||||
2
vips.go
2
vips.go
|
|
@ -65,7 +65,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicit thread-safe start of libvips.
|
// 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() {
|
func Initialize() {
|
||||||
if C.VIPS_MAJOR_VERSION <= 7 && C.VIPS_MINOR_VERSION < 40 {
|
if C.VIPS_MAJOR_VERSION <= 7 && C.VIPS_MINOR_VERSION < 40 {
|
||||||
panic("unsupported libvips version!")
|
panic("unsupported libvips version!")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue