How to blur an image in Golang?
Example
package main
import (
"os"
"image"
"image/jpeg"
"code.google.com/p/graphics-go/graphics"
)
func main() {
imagePath, _ := os.Open("pokeball.jpg")
defer imagePath.Close()
srcImage, _, _ := image.Decode(imagePath)
dstImage := image.NewRGBA(srcImage.Bounds())
// Blur Function
graphics.Blur(dstImage, srcImage, &graphics.BlurOptions{StdDev: 5.5})
newImage, _ := os.Create("blur.jpg")
defer newImage.Close()
jpeg.Encode(newImage, dstImage, &jpeg.Options{jpeg.DefaultQuality})
}
Most Helpful This Week
How To Make an HTTP Server in Golang?
Golang Functions Returning Multiple Values
Golang String Concatenation
How to replace emoji characters in string using regex in Golang?
Example to handle GET and POST request in Golang
How to write backslash in Golang string?
How to update content of a text file?
Regular expression to extract numbers from a string in Golang
Example to compare Println vs Printf
Add N number of Year, Month, Day, Hour, Minute, Second, Millisecond, Microsecond and Nanosecond to current date-time