Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/disintegration/imageorient
Go image decoding with respect to the EXIF orientation tag
https://github.com/disintegration/imageorient
decode exif fix go image orientation tag
Last synced: 3 months ago
JSON representation
Go image decoding with respect to the EXIF orientation tag
- Host: GitHub
- URL: https://github.com/disintegration/imageorient
- Owner: disintegration
- License: mit
- Created: 2017-03-31T00:03:52.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-20T19:55:49.000Z (over 6 years ago)
- Last Synced: 2024-06-18T15:38:05.881Z (8 months ago)
- Topics: decode, exif, fix, go, image, orientation, tag
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 69
- Watchers: 6
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# imageorient
[![GoDoc](https://godoc.org/github.com/disintegration/imageorient?status.svg)](https://godoc.org/github.com/disintegration/imageorient)
Package `imageorient` provides image decoding functions similar to standard library's
`image.Decode` and `image.DecodeConfig` with the addition that they also handle the
EXIF orientation tag (if present).License: MIT.
See also: http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/
## Install / Update
go get -u github.com/disintegration/imageorient
## Documentation
http://godoc.org/github.com/disintegration/imageorient
## Usage example
```go
package mainimport (
"image/jpeg"
"log"
"os""github.com/disintegration/imageorient"
)func main() {
// Open the test image. This particular image have the EXIF
// orientation tag set to 3 (rotated by 180 deg).
f, err := os.Open("testdata/orientation_3.jpg")
if err != nil {
log.Fatalf("os.Open failed: %v", err)
}// Decode the test image using the imageorient.Decode function
// to handle the image orientation correctly.
img, _, err := imageorient.Decode(f)
if err != nil {
log.Fatalf("imageorient.Decode failed: %v", err)
}// Save the decoded image to a new file. If we used image.Decode
// instead of imageorient.Decode on the previous step, the saved
// image would appear rotated.
f, err = os.Create("testdata/example_output.jpg")
if err != nil {
log.Fatalf("os.Create failed: %v", err)
}
err = jpeg.Encode(f, img, nil)
if err != nil {
log.Fatalf("jpeg.Encode failed: %v", err)
}
}
```