33 lines
711 B
Go
33 lines
711 B
Go
// Generate a deterministic synthetic JPEG without third-party dependencies.
|
|
package main
|
|
|
|
import (
|
|
"image"
|
|
"image/color"
|
|
"image/jpeg"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
if err := os.MkdirAll("data/upload-fixtures", 0755); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
file, err := os.Create("data/upload-fixtures/synthetic.jpg")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
img := image.NewRGBA(image.Rect(0, 0, 1024, 768))
|
|
for y := 0; y < 768; y++ {
|
|
for x := 0; x < 1024; x++ {
|
|
img.SetRGBA(x, y, color.RGBA{uint8(x*7 + y), uint8(y*11 + x), uint8(x ^ y), 255})
|
|
}
|
|
}
|
|
if err := jpeg.Encode(file, img, &jpeg.Options{Quality: 90}); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
if err := file.Close(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|