main.go 712 B

123456789101112131415161718192021222324252627
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "net"
  6. )
  7. func main() {
  8. const brotherPort int = 54921
  9. brotherIP := flag.String("a", "192.168.0.157", "IP address of the Brother scanner")
  10. resolution := flag.Int("r", 300, "Resolution of the scan")
  11. color := flag.String("c", "CGRAY", "Color mode of the scan (CGRAY, GRAY64)")
  12. adf := flag.Bool("m", false, "Enable scan of all pages from feeder")
  13. name := flag.String("n", "scan.jpg", "Name of the output file")
  14. flag.Parse()
  15. if net.ParseIP(*brotherIP) == nil {
  16. HandleError(fmt.Errorf("invalid IP address: %s", *brotherIP))
  17. }
  18. rawImage, width, heigth := Scan(*brotherIP, brotherPort, *resolution, *color, *adf)
  19. SaveImage(rawImage, width, heigth, *name, *color)
  20. }