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
How to wait for Goroutines to Finish Execution?
Converting Int data type to Float in Go
How to print string with double quote in Go?
Generate a Keygen of 256 bits
Dynamic JSON parser without Struct in Golang
How to get Dimensions of an image type jpg jpeg png or gif ?
How to iterate over a Map using for loop in Go?
How to import and alias package names?
Convert Int data type to Int16 Int32 Int64
How to extract text from between html tag using Regular Expressions in Golang?