package main
import (
"image"
"image/jpeg"
"log"
"os"
)
func main() {
log.SetFlags(log.Llongfile)
inFile, err := os.Open("input.jpg")
if err != nil {
log.Fatal(err)
}
defer inFile.Close()
src, err := jpeg.Decode(inFile)
if err != nil {
log.Fatal(err)
}
dst := image.NewRGBA(src.Bounds())
for x := src.Bounds().Min.X; x < src.Bounds().Max.X; x++ {
for y := src.Bounds().Min.Y; y < src.Bounds().Max.Y; y++ {
color := src.At(x, y)
dst.Set(src.Bounds().Max.X-x-1, y, color)
}
}
outFile, err := os.Create("output.jpg")
if err != nil {
log.Fatal(err)
}
defer outFile.Close()
err = jpeg.Encode(outFile, dst, &jpeg.Options{Quality: 100})
if err != nil {
log.Fatal(err)
}
}