To apply color correction and adjustment to an image in Go, you can use the github.com/disintegration/imaging
package. Here's an example of how you can do it:
go get -u github.com/disintegration/imaging
import (
"github.com/disintegration/imaging"
"image"
"image/color"
)
image.Image
object:srcImage, err := imaging.Open("path/to/your/image.jpg")
if err != nil {
log.Fatal(err)
}
sepiaImage := imaging.AdjustFunc(srcImage, func(c color.NRGBA) color.NRGBA {
return color.NRGBA{
R: uint8(float64(c.R)*0.393 + float64(c.G)*0.769 + float64(c.B)*0.189),
G: uint8(float64(c.R)*0.349 + float64(c.G)*0.686 + float64(c.B)*0.168),
B: uint8(float64(c.R)*0.272 + float64(c.G)*0.534 + float64(c.B)*0.131),
A: c.A,
}
})
err = imaging.Save(sepiaImage, "path/to/save/sepia_image.jpg")
if err != nil {
log.Fatal(err)
}
You can explore other functions provided by the imaging
package to perform various color correction and adjustments, such as changing brightness, contrast, saturation, etc.