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
Normal function parameter with variadic function parameter
How to reads and decodes JSON values from an input stream?
Print index and element or data from Array, Slice and Map
Split URL and Get Parameters from URL
Sample program to create csv and write data
How to use wildcard or a variable in our URL for complex routing?