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 print struct variables data in Golang?
Golang Read Write and Process data in CSV
Regular expression to validate common Credit Card Numbers
How to Unmarshal nested JSON structure?
Higher Order Functions in Golang
Various examples of Carbon date-time package in Golang
How to get the current date and time with timestamp in local and other timezones ?
Add N number of Year, Month, Day, Hour, Minute, Second, Millisecond, Microsecond and Nanosecond to current date-time
How can I convert a string variable into Boolean, Integer or Float type in Golang?
How to update content of a text file?