1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
diff --git a/src/jbig2.cc b/src/jbig2.cc
index 0bddb90..9447350 100644
--- a/src/jbig2.cc
+++ b/src/jbig2.cc
@@ -55,6 +55,7 @@ usage(const char *argv0) {
fprintf(stderr, " -S: remove images from mixed input and save separately\n");
fprintf(stderr, " -j --jpeg-output: write images from mixed input as JPEG\n");
fprintf(stderr, " -a --auto-thresh: use automatic thresholding in symbol encoder\n");
+ fprintf(stderr, " -D --dpi: force dpi\n");
fprintf(stderr, " --no-hash: disables use of hash function for automatic thresholding\n");
fprintf(stderr, " -V --version: version info\n");
fprintf(stderr, " -v: be verbose\n");
@@ -218,6 +219,7 @@ main(int argc, char **argv) {
bool segment = false;
bool auto_thresh = false;
bool hash = true;
+ int dpi = 0;
int i;
#ifdef WIN32
@@ -353,6 +355,24 @@ main(int argc, char **argv) {
continue;
}
+ if (strcmp(argv[i], "-D") == 0 ||
+ strcmp(argv[i], "--dpi") == 0) {
+ char *endptr;
+ long t_dpi = strtol(argv[i+1], &endptr, 10);
+ if (*endptr) {
+ fprintf(stderr, "Cannot parse int value: %s\n", argv[i+1]);
+ usage(argv[0]);
+ return 1;
+ }
+ if (t_dpi <= 0 || t_dpi > 9600) {
+ fprintf(stderr, "Invalid dpi: (1..9600)\n");
+ return 12;
+ }
+ dpi = (int)t_dpi;
+ i++;
+ continue;
+ }
+
break;
}
@@ -402,6 +422,11 @@ main(int argc, char **argv) {
source = pixReadTiff(argv[i], subimage++);
}
+ if (dpi != 0 && source->xres == 0 && source->yres == 0) {
+ source->xres = dpi;
+ source->yres = dpi;
+ }
+
if (!source) return 3;
if (verbose)
pixInfo(source, "source image:");
|