github.com/go-oss/image@v0.1.1-0.20230517025328-001b78555e78/README.md (about) 1 # image 2 3 `image/jpeg` base pure go image utility. 4 5 [![Go Reference][go-dev-img]][go-dev-url] 6 ![Test][github-actions-img] 7 [![codecov][codecov-img]][codecov-url] 8 [![Maintainability][codeclimate-img]][codeclimate-url] 9 [![Go Report Card][goreportcard-img]][goreportcard-url] 10 11 ## features 12 - Decode jpeg with quality value. 13 - Apply EXIF orientation to image pixels. 14 15 ## compatibility 16 - Go 1.13+ 17 18 ## usage 19 To install `imageutil` package: 20 21 ``` 22 go get github.com/go-oss/image/imageutil 23 ``` 24 25 Or, just use `jpeg` package: 26 27 ``` 28 go get github.com/go-oss/image/jpeg 29 ``` 30 31 ### example 32 ``` 33 img, err := imageutil.Decode(reader) 34 if err != nil { 35 log.Fatal(err) 36 } 37 38 // print metadata 39 fmt.Printf("Original MIME Type: %s", img.OriginalMIMEType) 40 fmt.Printf("Original Image Quality: %d", img.Quality) 41 42 // crop square 43 img.FitCrop() 44 45 // encode to jpeg image same original image quality 46 err = img.EncodeJPEG(ioutil.Discard) 47 if err != nil { 48 log.Fatal(err) 49 } 50 ``` 51 52 [go-dev-img]: https://pkg.go.dev/badge/github.com/go-oss/image.svg 53 [go-dev-url]: https://pkg.go.dev/github.com/go-oss/image 54 [github-actions-img]: https://github.com/go-oss/image/workflows/Test/badge.svg?branch=master 55 [codecov-img]: https://codecov.io/gh/go-oss/image/branch/master/graph/badge.svg 56 [codecov-url]: https://codecov.io/gh/go-oss/image 57 [codeclimate-img]: https://api.codeclimate.com/v1/badges/1d34d57d8c26f502ce7d/maintainability 58 [codeclimate-url]: https://codeclimate.com/github/go-oss/image/maintainability 59 [goreportcard-img]: https://goreportcard.com/badge/github.com/go-oss/image 60 [goreportcard-url]: https://goreportcard.com/report/github.com/go-oss/image