How to rotate an image?
External Google graphics package used to rotate the image.
Example
package main
import (
"os"
"math"
"image"
"image/jpeg"
"code.google.com/p/graphics-go/graphics"
)
func main() {
imagePath, _ := os.Open("jellyfish.jpg")
defer imagePath.Close()
srcImage, _, _ := image.Decode(imagePath)
srcDim := srcImage.Bounds()
dstImage := image.NewRGBA(image.Rect(0, 0, srcDim.Dy(), srcDim.Dx()))
graphics.Rotate(dstImage, srcImage, &graphics.RotateOptions{math.Pi / 2.0})
newImage, _ := os.Create("newjellyfish.jpg")
defer newImage.Close()
jpeg.Encode(newImage, dstImage, &jpeg.Options{jpeg.DefaultQuality})
}
Most Helpful This Week
Higher Order Functions in Golang
How to import structs from another package in Go?
How to Remove duplicate values from Slice?
How to find out element position in slice?
How can we reverse a simple string in Go?
What is GOPATH?
How pointer & and * and ** works in Golang?
How to get current IP form ipify.org ?
How to delete or remove element from a Map?
Example to handle GET and POST request in Golang