Преглед изворни кода

use forked image/tiff, explicitly set tiff dpi to match scan resolution

Corey Smith пре 4 година
родитељ
комит
74f1f66ed9
4 измењених фајлова са 14 додато и 5 уклоњено
  1. 4 1
      go.mod
  2. 5 0
      go.sum
  3. 3 2
      src/backend.go
  4. 2 2
      src/main.go

+ 4 - 1
go.mod

@@ -2,4 +2,7 @@ module github.com/corsmith/mfc-7820n
 
 go 1.17
 
-require golang.org/x/image v0.0.0-20211028202545-6944b10bf410 // indirect
+require (
+	github.com/corsmith/image v0.0.0-20220105164909-fcf1782a07e4 // indirect
+	golang.org/x/image v0.0.0-20211028202545-6944b10bf410 // indirect
+)

+ 5 - 0
go.sum

@@ -1,2 +1,7 @@
+github.com/corsmith/image v0.0.0-20220105164909-fcf1782a07e4 h1:zaLTw+dNlYUh76RX4u+1RxOX7jN4mImHAOD4gtesNtc=
+github.com/corsmith/image v0.0.0-20220105164909-fcf1782a07e4/go.mod h1:oQj9B6hDNfSuv2uZOgV65JE24iF3utOHbY+fs/al/IM=
 golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
 golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
+golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

+ 3 - 2
src/backend.go

@@ -4,7 +4,7 @@ import (
 	"encoding/binary"
 	"fmt"
 	"image"
-	"golang.org/x/image/tiff"
+	"github.com/corsmith/image/tiff"
 	"log"
 	"net"
 	"os"
@@ -118,7 +118,7 @@ readPackets:
 	return scanBytes, nil
 }
 
-func SaveImage(data []byte, width int, height int, name string, color string, debug bool) {
+func SaveImage(data []byte, width int, height int, name string, color string, debug bool, resolution int) {
 
 	log.Println("Saving image...")
 
@@ -151,6 +151,7 @@ func SaveImage(data []byte, width int, height int, name string, color string, de
 		var options tiff.Options = tiff.Options{
 			Compression: tiff.Deflate,
 			Predictor: true,
+			Resolution: uint32(resolution),
 		}
 
 		err = tiff.Encode(file, img, &options)

+ 2 - 2
src/main.go

@@ -26,9 +26,9 @@ func main() {
 
 	for i, rawImage := range rawImages {
 		if i == len(rawImages)-1 {
-			SaveImage(rawImage, width, height, fmt.Sprintf("%s-%d.tiff", *name, i), *color, *debug)
+			SaveImage(rawImage, width, height, fmt.Sprintf("%s-%d.tiff", *name, i), *color, *debug, *resolution)
 		} else {
-			go SaveImage(rawImage, width, height, fmt.Sprintf("%s-%d.tiff", *name, i), *color, *debug)
+			go SaveImage(rawImage, width, height, fmt.Sprintf("%s-%d.tiff", *name, i), *color, *debug, *resolution)
 		}
 	}
 }