Initial orientator

This commit is contained in:
2026-05-13 19:52:51 +03:00
commit 49fb60f831
24 changed files with 1919 additions and 0 deletions

41
cmd/testfixture/main.go Normal file
View File

@@ -0,0 +1,41 @@
// testfixture renders page 1 of a PDF as upright PNG and as a 90°-rotated PNG.
package main
import (
"fmt"
"image"
"image/png"
"os"
"github.com/gen2brain/go-fitz"
"orientator/internal/pipeline"
)
func main() {
if len(os.Args) < 4 {
fmt.Println("usage: testfixture <in.pdf> <upright.png> <rotated90.png>")
os.Exit(2)
}
doc, err := fitz.New(os.Args[1])
must(err)
defer doc.Close()
img, err := doc.ImageDPI(0, 150)
must(err)
writePNG(os.Args[2], img)
writePNG(os.Args[3], pipeline.RotateImage(img, 90))
fmt.Println("ok")
}
func writePNG(path string, img image.Image) {
f, err := os.Create(path)
must(err)
defer f.Close()
must(png.Encode(f, img))
}
func must(err error) {
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}