entangledstate-isbn 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/Rakefile +0 -18
- data/VERSION +1 -0
- data/isbn.gemspec +290 -7
- data/lib/isbn.rb +6 -6
- data/src/gocr-0.48/.cvsignore +6 -0
- data/src/gocr-0.48/AUTHORS +7 -0
- data/src/gocr-0.48/BUGS +55 -0
- data/src/gocr-0.48/CREDITS +17 -0
- data/src/gocr-0.48/HISTORY +243 -0
- data/src/gocr-0.48/INSTALL +83 -0
- data/src/gocr-0.48/Makefile +193 -0
- data/src/gocr-0.48/Makefile.in +193 -0
- data/src/gocr-0.48/README +165 -0
- data/src/gocr-0.48/READMEde.txt +80 -0
- data/src/gocr-0.48/REMARK.txt +18 -0
- data/src/gocr-0.48/REVIEW +538 -0
- data/src/gocr-0.48/TODO +65 -0
- data/src/gocr-0.48/bin/.cvsignore +2 -0
- data/src/gocr-0.48/bin/create_db +38 -0
- data/src/gocr-0.48/bin/gocr.tcl +527 -0
- data/src/gocr-0.48/bin/gocr_chk.sh +44 -0
- data/src/gocr-0.48/configure +4689 -0
- data/src/gocr-0.48/configure.in +71 -0
- data/src/gocr-0.48/doc/.#Makefile.1.6 +39 -0
- data/src/gocr-0.48/doc/.cvsignore +2 -0
- data/src/gocr-0.48/doc/Makefile +39 -0
- data/src/gocr-0.48/doc/Makefile.in +39 -0
- data/src/gocr-0.48/doc/example.dtd +53 -0
- data/src/gocr-0.48/doc/example.xml +21 -0
- data/src/gocr-0.48/doc/examples.txt +67 -0
- data/src/gocr-0.48/doc/gocr.html +578 -0
- data/src/gocr-0.48/doc/unicode.txt +57 -0
- data/src/gocr-0.48/examples/.#Makefile.1.22 +166 -0
- data/src/gocr-0.48/examples/4x6.png +0 -0
- data/src/gocr-0.48/examples/4x6.txt +2 -0
- data/src/gocr-0.48/examples/5x7.png +0 -0
- data/src/gocr-0.48/examples/5x7.png.txt +2 -0
- data/src/gocr-0.48/examples/5x8.png +0 -0
- data/src/gocr-0.48/examples/5x8.png.txt +2 -0
- data/src/gocr-0.48/examples/Makefile +166 -0
- data/src/gocr-0.48/examples/color.fig +20 -0
- data/src/gocr-0.48/examples/ex.fig +16 -0
- data/src/gocr-0.48/examples/font.tex +22 -0
- data/src/gocr-0.48/examples/font1.tex +46 -0
- data/src/gocr-0.48/examples/font2.fig +27 -0
- data/src/gocr-0.48/examples/font_nw.tex +24 -0
- data/src/gocr-0.48/examples/handwrt1.jpg +0 -0
- data/src/gocr-0.48/examples/handwrt1.txt +10 -0
- data/src/gocr-0.48/examples/inverse.fig +20 -0
- data/src/gocr-0.48/examples/matrix.jpg +0 -0
- data/src/gocr-0.48/examples/ocr-a-subset.png +0 -0
- data/src/gocr-0.48/examples/ocr-a-subset.png.txt +4 -0
- data/src/gocr-0.48/examples/ocr-a.png +0 -0
- data/src/gocr-0.48/examples/ocr-a.txt +6 -0
- data/src/gocr-0.48/examples/ocr-b.png +0 -0
- data/src/gocr-0.48/examples/ocr-b.png.txt +4 -0
- data/src/gocr-0.48/examples/polish.tex +28 -0
- data/src/gocr-0.48/examples/rotate45.fig +14 -0
- data/src/gocr-0.48/examples/score +36 -0
- data/src/gocr-0.48/examples/text.tex +28 -0
- data/src/gocr-0.48/gocr.spec +143 -0
- data/src/gocr-0.48/gpl.html +537 -0
- data/src/gocr-0.48/include/.cvsignore +2 -0
- data/src/gocr-0.48/include/config.h +36 -0
- data/src/gocr-0.48/include/config.h.in +36 -0
- data/src/gocr-0.48/include/version.h +2 -0
- data/src/gocr-0.48/install-sh +3 -0
- data/src/gocr-0.48/make.bat +57 -0
- data/src/gocr-0.48/man/.cvsignore +2 -0
- data/src/gocr-0.48/man/Makefile +29 -0
- data/src/gocr-0.48/man/Makefile.in +29 -0
- data/src/gocr-0.48/man/man1/gocr.1 +166 -0
- data/src/gocr-0.48/src/.cvsignore +4 -0
- data/src/gocr-0.48/src/Makefile +132 -0
- data/src/gocr-0.48/src/Makefile.in +132 -0
- data/src/gocr-0.48/src/amiga.h +31 -0
- data/src/gocr-0.48/src/barcode.c +846 -0
- data/src/gocr-0.48/src/barcode.c.orig +593 -0
- data/src/gocr-0.48/src/barcode.h +11 -0
- data/src/gocr-0.48/src/box.c +372 -0
- data/src/gocr-0.48/src/database.c +462 -0
- data/src/gocr-0.48/src/detect.c +943 -0
- data/src/gocr-0.48/src/gocr.c +373 -0
- data/src/gocr-0.48/src/gocr.h +288 -0
- data/src/gocr-0.48/src/jconv.c +168 -0
- data/src/gocr-0.48/src/job.c +84 -0
- data/src/gocr-0.48/src/lines.c +350 -0
- data/src/gocr-0.48/src/list.c +334 -0
- data/src/gocr-0.48/src/list.h +90 -0
- data/src/gocr-0.48/src/ocr0.c +6756 -0
- data/src/gocr-0.48/src/ocr0.h +63 -0
- data/src/gocr-0.48/src/ocr0n.c +1475 -0
- data/src/gocr-0.48/src/ocr1.c +85 -0
- data/src/gocr-0.48/src/ocr1.h +3 -0
- data/src/gocr-0.48/src/otsu.c +289 -0
- data/src/gocr-0.48/src/otsu.h +23 -0
- data/src/gocr-0.48/src/output.c +289 -0
- data/src/gocr-0.48/src/output.h +37 -0
- data/src/gocr-0.48/src/pcx.c +153 -0
- data/src/gocr-0.48/src/pcx.h +9 -0
- data/src/gocr-0.48/src/pgm2asc.c +2893 -0
- data/src/gocr-0.48/src/pgm2asc.h +105 -0
- data/src/gocr-0.48/src/pixel.c +537 -0
- data/src/gocr-0.48/src/pnm.c +533 -0
- data/src/gocr-0.48/src/pnm.h +35 -0
- data/src/gocr-0.48/src/progress.c +87 -0
- data/src/gocr-0.48/src/progress.h +42 -0
- data/src/gocr-0.48/src/remove.c +703 -0
- data/src/gocr-0.48/src/tga.c +87 -0
- data/src/gocr-0.48/src/tga.h +6 -0
- data/src/gocr-0.48/src/unicode.c +1314 -0
- data/src/gocr-0.48/src/unicode.h +1257 -0
- data/src/jpeg-7/Makefile.am +133 -0
- data/src/jpeg-7/Makefile.in +1089 -0
- data/src/jpeg-7/README +322 -0
- data/src/jpeg-7/aclocal.m4 +8990 -0
- data/src/jpeg-7/ansi2knr.1 +36 -0
- data/src/jpeg-7/ansi2knr.c +739 -0
- data/src/jpeg-7/cderror.h +132 -0
- data/src/jpeg-7/cdjpeg.c +181 -0
- data/src/jpeg-7/cdjpeg.h +187 -0
- data/src/jpeg-7/change.log +270 -0
- data/src/jpeg-7/cjpeg.1 +325 -0
- data/src/jpeg-7/cjpeg.c +616 -0
- data/src/jpeg-7/ckconfig.c +402 -0
- data/src/jpeg-7/coderules.txt +118 -0
- data/src/jpeg-7/config.guess +1561 -0
- data/src/jpeg-7/config.sub +1686 -0
- data/src/jpeg-7/configure +17139 -0
- data/src/jpeg-7/configure.ac +317 -0
- data/src/jpeg-7/depcomp +630 -0
- data/src/jpeg-7/djpeg.1 +251 -0
- data/src/jpeg-7/djpeg.c +617 -0
- data/src/jpeg-7/example.c +433 -0
- data/src/jpeg-7/filelist.txt +215 -0
- data/src/jpeg-7/install-sh +520 -0
- data/src/jpeg-7/install.txt +1097 -0
- data/src/jpeg-7/jaricom.c +148 -0
- data/src/jpeg-7/jcapimin.c +282 -0
- data/src/jpeg-7/jcapistd.c +161 -0
- data/src/jpeg-7/jcarith.c +921 -0
- data/src/jpeg-7/jccoefct.c +453 -0
- data/src/jpeg-7/jccolor.c +459 -0
- data/src/jpeg-7/jcdctmgr.c +482 -0
- data/src/jpeg-7/jchuff.c +1612 -0
- data/src/jpeg-7/jcinit.c +65 -0
- data/src/jpeg-7/jcmainct.c +293 -0
- data/src/jpeg-7/jcmarker.c +667 -0
- data/src/jpeg-7/jcmaster.c +770 -0
- data/src/jpeg-7/jcomapi.c +106 -0
- data/src/jpeg-7/jconfig.bcc +48 -0
- data/src/jpeg-7/jconfig.cfg +45 -0
- data/src/jpeg-7/jconfig.dj +38 -0
- data/src/jpeg-7/jconfig.mac +43 -0
- data/src/jpeg-7/jconfig.manx +43 -0
- data/src/jpeg-7/jconfig.mc6 +52 -0
- data/src/jpeg-7/jconfig.sas +43 -0
- data/src/jpeg-7/jconfig.st +42 -0
- data/src/jpeg-7/jconfig.txt +155 -0
- data/src/jpeg-7/jconfig.vc +45 -0
- data/src/jpeg-7/jconfig.vms +37 -0
- data/src/jpeg-7/jconfig.wat +38 -0
- data/src/jpeg-7/jcparam.c +632 -0
- data/src/jpeg-7/jcprepct.c +358 -0
- data/src/jpeg-7/jcsample.c +545 -0
- data/src/jpeg-7/jctrans.c +381 -0
- data/src/jpeg-7/jdapimin.c +396 -0
- data/src/jpeg-7/jdapistd.c +275 -0
- data/src/jpeg-7/jdarith.c +762 -0
- data/src/jpeg-7/jdatadst.c +151 -0
- data/src/jpeg-7/jdatasrc.c +212 -0
- data/src/jpeg-7/jdcoefct.c +736 -0
- data/src/jpeg-7/jdcolor.c +396 -0
- data/src/jpeg-7/jdct.h +393 -0
- data/src/jpeg-7/jddctmgr.c +382 -0
- data/src/jpeg-7/jdhuff.c +1309 -0
- data/src/jpeg-7/jdinput.c +384 -0
- data/src/jpeg-7/jdmainct.c +512 -0
- data/src/jpeg-7/jdmarker.c +1360 -0
- data/src/jpeg-7/jdmaster.c +663 -0
- data/src/jpeg-7/jdmerge.c +400 -0
- data/src/jpeg-7/jdpostct.c +290 -0
- data/src/jpeg-7/jdsample.c +361 -0
- data/src/jpeg-7/jdtrans.c +136 -0
- data/src/jpeg-7/jerror.c +252 -0
- data/src/jpeg-7/jerror.h +304 -0
- data/src/jpeg-7/jfdctflt.c +174 -0
- data/src/jpeg-7/jfdctfst.c +230 -0
- data/src/jpeg-7/jfdctint.c +4348 -0
- data/src/jpeg-7/jidctflt.c +242 -0
- data/src/jpeg-7/jidctfst.c +368 -0
- data/src/jpeg-7/jidctint.c +5137 -0
- data/src/jpeg-7/jinclude.h +91 -0
- data/src/jpeg-7/jmemansi.c +167 -0
- data/src/jpeg-7/jmemdos.c +638 -0
- data/src/jpeg-7/jmemdosa.asm +379 -0
- data/src/jpeg-7/jmemmac.c +289 -0
- data/src/jpeg-7/jmemmgr.c +1118 -0
- data/src/jpeg-7/jmemname.c +276 -0
- data/src/jpeg-7/jmemnobs.c +109 -0
- data/src/jpeg-7/jmemsys.h +198 -0
- data/src/jpeg-7/jmorecfg.h +369 -0
- data/src/jpeg-7/jpegint.h +395 -0
- data/src/jpeg-7/jpeglib.h +1135 -0
- data/src/jpeg-7/jpegtran.1 +272 -0
- data/src/jpeg-7/jpegtran.c +546 -0
- data/src/jpeg-7/jquant1.c +856 -0
- data/src/jpeg-7/jquant2.c +1310 -0
- data/src/jpeg-7/jutils.c +179 -0
- data/src/jpeg-7/jversion.h +14 -0
- data/src/jpeg-7/libjpeg.map +4 -0
- data/src/jpeg-7/libjpeg.txt +3067 -0
- data/src/jpeg-7/ltmain.sh +8406 -0
- data/src/jpeg-7/makcjpeg.st +36 -0
- data/src/jpeg-7/makdjpeg.st +36 -0
- data/src/jpeg-7/makeadsw.vc6 +77 -0
- data/src/jpeg-7/makeasln.vc9 +33 -0
- data/src/jpeg-7/makecdep.vc6 +82 -0
- data/src/jpeg-7/makecdsp.vc6 +130 -0
- data/src/jpeg-7/makecmak.vc6 +159 -0
- data/src/jpeg-7/makecvcp.vc9 +186 -0
- data/src/jpeg-7/makeddep.vc6 +82 -0
- data/src/jpeg-7/makeddsp.vc6 +130 -0
- data/src/jpeg-7/makedmak.vc6 +159 -0
- data/src/jpeg-7/makedvcp.vc9 +186 -0
- data/src/jpeg-7/makefile.ansi +220 -0
- data/src/jpeg-7/makefile.bcc +291 -0
- data/src/jpeg-7/makefile.dj +226 -0
- data/src/jpeg-7/makefile.manx +220 -0
- data/src/jpeg-7/makefile.mc6 +255 -0
- data/src/jpeg-7/makefile.mms +224 -0
- data/src/jpeg-7/makefile.sas +258 -0
- data/src/jpeg-7/makefile.unix +234 -0
- data/src/jpeg-7/makefile.vc +217 -0
- data/src/jpeg-7/makefile.vms +142 -0
- data/src/jpeg-7/makefile.wat +239 -0
- data/src/jpeg-7/makejdep.vc6 +423 -0
- data/src/jpeg-7/makejdsp.vc6 +285 -0
- data/src/jpeg-7/makejdsw.vc6 +29 -0
- data/src/jpeg-7/makejmak.vc6 +425 -0
- data/src/jpeg-7/makejsln.vc9 +17 -0
- data/src/jpeg-7/makejvcp.vc9 +328 -0
- data/src/jpeg-7/makeproj.mac +213 -0
- data/src/jpeg-7/makerdep.vc6 +6 -0
- data/src/jpeg-7/makerdsp.vc6 +78 -0
- data/src/jpeg-7/makermak.vc6 +110 -0
- data/src/jpeg-7/makervcp.vc9 +133 -0
- data/src/jpeg-7/maketdep.vc6 +43 -0
- data/src/jpeg-7/maketdsp.vc6 +122 -0
- data/src/jpeg-7/maketmak.vc6 +131 -0
- data/src/jpeg-7/maketvcp.vc9 +178 -0
- data/src/jpeg-7/makewdep.vc6 +6 -0
- data/src/jpeg-7/makewdsp.vc6 +78 -0
- data/src/jpeg-7/makewmak.vc6 +110 -0
- data/src/jpeg-7/makewvcp.vc9 +133 -0
- data/src/jpeg-7/makljpeg.st +68 -0
- data/src/jpeg-7/maktjpeg.st +30 -0
- data/src/jpeg-7/makvms.opt +4 -0
- data/src/jpeg-7/missing +376 -0
- data/src/jpeg-7/rdbmp.c +439 -0
- data/src/jpeg-7/rdcolmap.c +253 -0
- data/src/jpeg-7/rdgif.c +38 -0
- data/src/jpeg-7/rdjpgcom.1 +63 -0
- data/src/jpeg-7/rdjpgcom.c +515 -0
- data/src/jpeg-7/rdppm.c +459 -0
- data/src/jpeg-7/rdrle.c +387 -0
- data/src/jpeg-7/rdswitch.c +365 -0
- data/src/jpeg-7/rdtarga.c +500 -0
- data/src/jpeg-7/structure.txt +945 -0
- data/src/jpeg-7/testimg.bmp +0 -0
- data/src/jpeg-7/testimg.jpg +0 -0
- data/src/jpeg-7/testimg.ppm +4 -0
- data/src/jpeg-7/testimgp.jpg +0 -0
- data/src/jpeg-7/testorig.jpg +0 -0
- data/src/jpeg-7/testprog.jpg +0 -0
- data/src/jpeg-7/transupp.c +1533 -0
- data/src/jpeg-7/transupp.h +205 -0
- data/src/jpeg-7/usage.txt +605 -0
- data/src/jpeg-7/wizard.txt +211 -0
- data/src/jpeg-7/wrbmp.c +442 -0
- data/src/jpeg-7/wrgif.c +399 -0
- data/src/jpeg-7/wrjpgcom.1 +103 -0
- data/src/jpeg-7/wrjpgcom.c +583 -0
- data/src/jpeg-7/wrppm.c +269 -0
- data/src/jpeg-7/wrrle.c +305 -0
- data/src/jpeg-7/wrtarga.c +253 -0
- metadata +287 -6
- data/LICENSE +0 -20
- data/VERSION.yml +0 -4
@@ -0,0 +1,272 @@
|
|
1
|
+
.TH JPEGTRAN 1 "28 March 2009"
|
2
|
+
.SH NAME
|
3
|
+
jpegtran \- lossless transformation of JPEG files
|
4
|
+
.SH SYNOPSIS
|
5
|
+
.B jpegtran
|
6
|
+
[
|
7
|
+
.I options
|
8
|
+
]
|
9
|
+
[
|
10
|
+
.I filename
|
11
|
+
]
|
12
|
+
.LP
|
13
|
+
.SH DESCRIPTION
|
14
|
+
.LP
|
15
|
+
.B jpegtran
|
16
|
+
performs various useful transformations of JPEG files.
|
17
|
+
It can translate the coded representation from one variant of JPEG to another,
|
18
|
+
for example from baseline JPEG to progressive JPEG or vice versa. It can also
|
19
|
+
perform some rearrangements of the image data, for example turning an image
|
20
|
+
from landscape to portrait format by rotation.
|
21
|
+
.PP
|
22
|
+
.B jpegtran
|
23
|
+
works by rearranging the compressed data (DCT coefficients), without
|
24
|
+
ever fully decoding the image. Therefore, its transformations are lossless:
|
25
|
+
there is no image degradation at all, which would not be true if you used
|
26
|
+
.B djpeg
|
27
|
+
followed by
|
28
|
+
.B cjpeg
|
29
|
+
to accomplish the same conversion. But by the same token,
|
30
|
+
.B jpegtran
|
31
|
+
cannot perform lossy operations such as changing the image quality.
|
32
|
+
.PP
|
33
|
+
.B jpegtran
|
34
|
+
reads the named JPEG/JFIF file, or the standard input if no file is
|
35
|
+
named, and produces a JPEG/JFIF file on the standard output.
|
36
|
+
.SH OPTIONS
|
37
|
+
All switch names may be abbreviated; for example,
|
38
|
+
.B \-optimize
|
39
|
+
may be written
|
40
|
+
.B \-opt
|
41
|
+
or
|
42
|
+
.BR \-o .
|
43
|
+
Upper and lower case are equivalent.
|
44
|
+
British spellings are also accepted (e.g.,
|
45
|
+
.BR \-optimise ),
|
46
|
+
though for brevity these are not mentioned below.
|
47
|
+
.PP
|
48
|
+
To specify the coded JPEG representation used in the output file,
|
49
|
+
.B jpegtran
|
50
|
+
accepts a subset of the switches recognized by
|
51
|
+
.BR cjpeg :
|
52
|
+
.TP
|
53
|
+
.B \-optimize
|
54
|
+
Perform optimization of entropy encoding parameters.
|
55
|
+
.TP
|
56
|
+
.B \-progressive
|
57
|
+
Create progressive JPEG file.
|
58
|
+
.TP
|
59
|
+
.BI \-restart " N"
|
60
|
+
Emit a JPEG restart marker every N MCU rows, or every N MCU blocks if "B" is
|
61
|
+
attached to the number.
|
62
|
+
.TP
|
63
|
+
.B \-arithmetic
|
64
|
+
Use arithmetic coding.
|
65
|
+
.TP
|
66
|
+
.BI \-scans " file"
|
67
|
+
Use the scan script given in the specified text file.
|
68
|
+
.PP
|
69
|
+
See
|
70
|
+
.BR cjpeg (1)
|
71
|
+
for more details about these switches.
|
72
|
+
If you specify none of these switches, you get a plain baseline-JPEG output
|
73
|
+
file. The quality setting and so forth are determined by the input file.
|
74
|
+
.PP
|
75
|
+
The image can be losslessly transformed by giving one of these switches:
|
76
|
+
.TP
|
77
|
+
.B \-flip horizontal
|
78
|
+
Mirror image horizontally (left-right).
|
79
|
+
.TP
|
80
|
+
.B \-flip vertical
|
81
|
+
Mirror image vertically (top-bottom).
|
82
|
+
.TP
|
83
|
+
.B \-rotate 90
|
84
|
+
Rotate image 90 degrees clockwise.
|
85
|
+
.TP
|
86
|
+
.B \-rotate 180
|
87
|
+
Rotate image 180 degrees.
|
88
|
+
.TP
|
89
|
+
.B \-rotate 270
|
90
|
+
Rotate image 270 degrees clockwise (or 90 ccw).
|
91
|
+
.TP
|
92
|
+
.B \-transpose
|
93
|
+
Transpose image (across UL-to-LR axis).
|
94
|
+
.TP
|
95
|
+
.B \-transverse
|
96
|
+
Transverse transpose (across UR-to-LL axis).
|
97
|
+
.IP
|
98
|
+
The transpose transformation has no restrictions regarding image dimensions.
|
99
|
+
The other transformations operate rather oddly if the image dimensions are not
|
100
|
+
a multiple of the iMCU size (usually 8 or 16 pixels), because they can only
|
101
|
+
transform complete blocks of DCT coefficient data in the desired way.
|
102
|
+
.IP
|
103
|
+
.BR jpegtran 's
|
104
|
+
default behavior when transforming an odd-size image is designed
|
105
|
+
to preserve exact reversibility and mathematical consistency of the
|
106
|
+
transformation set. As stated, transpose is able to flip the entire image
|
107
|
+
area. Horizontal mirroring leaves any partial iMCU column at the right edge
|
108
|
+
untouched, but is able to flip all rows of the image. Similarly, vertical
|
109
|
+
mirroring leaves any partial iMCU row at the bottom edge untouched, but is
|
110
|
+
able to flip all columns. The other transforms can be built up as sequences
|
111
|
+
of transpose and flip operations; for consistency, their actions on edge
|
112
|
+
pixels are defined to be the same as the end result of the corresponding
|
113
|
+
transpose-and-flip sequence.
|
114
|
+
.IP
|
115
|
+
For practical use, you may prefer to discard any untransformable edge pixels
|
116
|
+
rather than having a strange-looking strip along the right and/or bottom edges
|
117
|
+
of a transformed image. To do this, add the
|
118
|
+
.B \-trim
|
119
|
+
switch:
|
120
|
+
.TP
|
121
|
+
.B \-trim
|
122
|
+
Drop non-transformable edge blocks.
|
123
|
+
.IP
|
124
|
+
Obviously, a transformation with
|
125
|
+
.B \-trim
|
126
|
+
is not reversible, so strictly speaking
|
127
|
+
.B jpegtran
|
128
|
+
with this switch is not lossless. Also, the expected mathematical
|
129
|
+
equivalences between the transformations no longer hold. For example,
|
130
|
+
.B \-rot 270 -trim
|
131
|
+
trims only the bottom edge, but
|
132
|
+
.B \-rot 90 -trim
|
133
|
+
followed by
|
134
|
+
.B \-rot 180 -trim
|
135
|
+
trims both edges.
|
136
|
+
.IP
|
137
|
+
If you are only interested in perfect transformation, add the
|
138
|
+
.B \-perfect
|
139
|
+
switch:
|
140
|
+
.TP
|
141
|
+
.B \-perfect
|
142
|
+
Fails with an error if the transformation is not perfect.
|
143
|
+
.IP
|
144
|
+
For example you may want to do
|
145
|
+
.IP
|
146
|
+
.B (jpegtran \-rot 90 -perfect
|
147
|
+
.I foo.jpg
|
148
|
+
.B || djpeg
|
149
|
+
.I foo.jpg
|
150
|
+
.B | pnmflip \-r90 | cjpeg)
|
151
|
+
.IP
|
152
|
+
to do a perfect rotation if available or an approximated one if not.
|
153
|
+
.PP
|
154
|
+
We also offer a lossless-crop option, which discards data outside a given
|
155
|
+
image region but losslessly preserves what is inside. Like the rotate and
|
156
|
+
flip transforms, lossless crop is restricted by the current JPEG format: the
|
157
|
+
upper left corner of the selected region must fall on an iMCU boundary. If
|
158
|
+
this does not hold for the given crop parameters, we silently move the upper
|
159
|
+
left corner up and/or left to make it so, simultaneously increasing the region
|
160
|
+
dimensions to keep the lower right crop corner unchanged. (Thus, the output
|
161
|
+
image covers at least the requested region, but may cover more.)
|
162
|
+
|
163
|
+
The image can be losslessly cropped by giving the switch:
|
164
|
+
.TP
|
165
|
+
.B \-crop WxH+X+Y
|
166
|
+
Crop to a rectangular subarea of width W, height H starting at point X,Y.
|
167
|
+
.PP
|
168
|
+
Another not-strictly-lossless transformation switch is:
|
169
|
+
.TP
|
170
|
+
.B \-grayscale
|
171
|
+
Force grayscale output.
|
172
|
+
.IP
|
173
|
+
This option discards the chrominance channels if the input image is YCbCr
|
174
|
+
(ie, a standard color JPEG), resulting in a grayscale JPEG file. The
|
175
|
+
luminance channel is preserved exactly, so this is a better method of reducing
|
176
|
+
to grayscale than decompression, conversion, and recompression. This switch
|
177
|
+
is particularly handy for fixing a monochrome picture that was mistakenly
|
178
|
+
encoded as a color JPEG. (In such a case, the space savings from getting rid
|
179
|
+
of the near-empty chroma channels won't be large; but the decoding time for
|
180
|
+
a grayscale JPEG is substantially less than that for a color JPEG.)
|
181
|
+
.PP
|
182
|
+
.B jpegtran
|
183
|
+
also recognizes these switches that control what to do with "extra" markers,
|
184
|
+
such as comment blocks:
|
185
|
+
.TP
|
186
|
+
.B \-copy none
|
187
|
+
Copy no extra markers from source file. This setting suppresses all
|
188
|
+
comments and other excess baggage present in the source file.
|
189
|
+
.TP
|
190
|
+
.B \-copy comments
|
191
|
+
Copy only comment markers. This setting copies comments from the source file,
|
192
|
+
but discards any other inessential (for image display) data.
|
193
|
+
.TP
|
194
|
+
.B \-copy all
|
195
|
+
Copy all extra markers. This setting preserves miscellaneous markers
|
196
|
+
found in the source file, such as JFIF thumbnails, Exif data, and Photoshop
|
197
|
+
settings. In some files these extra markers can be sizable.
|
198
|
+
.IP
|
199
|
+
The default behavior is
|
200
|
+
.BR "\-copy comments" .
|
201
|
+
(Note: in IJG releases v6 and v6a,
|
202
|
+
.B jpegtran
|
203
|
+
always did the equivalent of
|
204
|
+
.BR "\-copy none" .)
|
205
|
+
.PP
|
206
|
+
Additional switches recognized by jpegtran are:
|
207
|
+
.TP
|
208
|
+
.BI \-maxmemory " N"
|
209
|
+
Set limit for amount of memory to use in processing large images. Value is
|
210
|
+
in thousands of bytes, or millions of bytes if "M" is attached to the
|
211
|
+
number. For example,
|
212
|
+
.B \-max 4m
|
213
|
+
selects 4000000 bytes. If more space is needed, temporary files will be used.
|
214
|
+
.TP
|
215
|
+
.BI \-outfile " name"
|
216
|
+
Send output image to the named file, not to standard output.
|
217
|
+
.TP
|
218
|
+
.B \-verbose
|
219
|
+
Enable debug printout. More
|
220
|
+
.BR \-v 's
|
221
|
+
give more output. Also, version information is printed at startup.
|
222
|
+
.TP
|
223
|
+
.B \-debug
|
224
|
+
Same as
|
225
|
+
.BR \-verbose .
|
226
|
+
.SH EXAMPLES
|
227
|
+
.LP
|
228
|
+
This example converts a baseline JPEG file to progressive form:
|
229
|
+
.IP
|
230
|
+
.B jpegtran \-progressive
|
231
|
+
.I foo.jpg
|
232
|
+
.B >
|
233
|
+
.I fooprog.jpg
|
234
|
+
.PP
|
235
|
+
This example rotates an image 90 degrees clockwise, discarding any
|
236
|
+
unrotatable edge pixels:
|
237
|
+
.IP
|
238
|
+
.B jpegtran \-rot 90 -trim
|
239
|
+
.I foo.jpg
|
240
|
+
.B >
|
241
|
+
.I foo90.jpg
|
242
|
+
.SH ENVIRONMENT
|
243
|
+
.TP
|
244
|
+
.B JPEGMEM
|
245
|
+
If this environment variable is set, its value is the default memory limit.
|
246
|
+
The value is specified as described for the
|
247
|
+
.B \-maxmemory
|
248
|
+
switch.
|
249
|
+
.B JPEGMEM
|
250
|
+
overrides the default value specified when the program was compiled, and
|
251
|
+
itself is overridden by an explicit
|
252
|
+
.BR \-maxmemory .
|
253
|
+
.SH SEE ALSO
|
254
|
+
.BR cjpeg (1),
|
255
|
+
.BR djpeg (1),
|
256
|
+
.BR rdjpgcom (1),
|
257
|
+
.BR wrjpgcom (1)
|
258
|
+
.br
|
259
|
+
Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
|
260
|
+
Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
|
261
|
+
.SH AUTHOR
|
262
|
+
Independent JPEG Group
|
263
|
+
.SH BUGS
|
264
|
+
The transform options can't transform odd-size images perfectly. Use
|
265
|
+
.B \-trim
|
266
|
+
or
|
267
|
+
.B \-perfect
|
268
|
+
if you don't like the results.
|
269
|
+
.PP
|
270
|
+
The entire image is read into memory and then written out again, even in
|
271
|
+
cases where this isn't really necessary. Expect swapping on large images,
|
272
|
+
especially when using the more complex transform options.
|
@@ -0,0 +1,546 @@
|
|
1
|
+
/*
|
2
|
+
* jpegtran.c
|
3
|
+
*
|
4
|
+
* Copyright (C) 1995-2001, Thomas G. Lane.
|
5
|
+
* This file is part of the Independent JPEG Group's software.
|
6
|
+
* For conditions of distribution and use, see the accompanying README file.
|
7
|
+
*
|
8
|
+
* This file contains a command-line user interface for JPEG transcoding.
|
9
|
+
* It is very similar to cjpeg.c, but provides lossless transcoding between
|
10
|
+
* different JPEG file formats. It also provides some lossless and sort-of-
|
11
|
+
* lossless transformations of JPEG data.
|
12
|
+
*/
|
13
|
+
|
14
|
+
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
15
|
+
#include "transupp.h" /* Support routines for jpegtran */
|
16
|
+
#include "jversion.h" /* for version message */
|
17
|
+
|
18
|
+
#ifdef USE_CCOMMAND /* command-line reader for Macintosh */
|
19
|
+
#ifdef __MWERKS__
|
20
|
+
#include <SIOUX.h> /* Metrowerks needs this */
|
21
|
+
#include <console.h> /* ... and this */
|
22
|
+
#endif
|
23
|
+
#ifdef THINK_C
|
24
|
+
#include <console.h> /* Think declares it here */
|
25
|
+
#endif
|
26
|
+
#endif
|
27
|
+
|
28
|
+
|
29
|
+
/*
|
30
|
+
* Argument-parsing code.
|
31
|
+
* The switch parser is designed to be useful with DOS-style command line
|
32
|
+
* syntax, ie, intermixed switches and file names, where only the switches
|
33
|
+
* to the left of a given file name affect processing of that file.
|
34
|
+
* The main program in this file doesn't actually use this capability...
|
35
|
+
*/
|
36
|
+
|
37
|
+
|
38
|
+
static const char * progname; /* program name for error messages */
|
39
|
+
static char * outfilename; /* for -outfile switch */
|
40
|
+
static JCOPY_OPTION copyoption; /* -copy switch */
|
41
|
+
static jpeg_transform_info transformoption; /* image transformation options */
|
42
|
+
|
43
|
+
|
44
|
+
LOCAL(void)
|
45
|
+
usage (void)
|
46
|
+
/* complain about bad command line */
|
47
|
+
{
|
48
|
+
fprintf(stderr, "usage: %s [switches] ", progname);
|
49
|
+
#ifdef TWO_FILE_COMMANDLINE
|
50
|
+
fprintf(stderr, "inputfile outputfile\n");
|
51
|
+
#else
|
52
|
+
fprintf(stderr, "[inputfile]\n");
|
53
|
+
#endif
|
54
|
+
|
55
|
+
fprintf(stderr, "Switches (names may be abbreviated):\n");
|
56
|
+
fprintf(stderr, " -copy none Copy no extra markers from source file\n");
|
57
|
+
fprintf(stderr, " -copy comments Copy only comment markers (default)\n");
|
58
|
+
fprintf(stderr, " -copy all Copy all extra markers\n");
|
59
|
+
#ifdef ENTROPY_OPT_SUPPORTED
|
60
|
+
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
|
61
|
+
#endif
|
62
|
+
#ifdef C_PROGRESSIVE_SUPPORTED
|
63
|
+
fprintf(stderr, " -progressive Create progressive JPEG file\n");
|
64
|
+
#endif
|
65
|
+
#if TRANSFORMS_SUPPORTED
|
66
|
+
fprintf(stderr, "Switches for modifying the image:\n");
|
67
|
+
fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular subarea\n");
|
68
|
+
fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n");
|
69
|
+
fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n");
|
70
|
+
fprintf(stderr, " -perfect Fail if there is non-transformable edge blocks\n");
|
71
|
+
fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n");
|
72
|
+
fprintf(stderr, " -transpose Transpose image\n");
|
73
|
+
fprintf(stderr, " -transverse Transverse transpose image\n");
|
74
|
+
fprintf(stderr, " -trim Drop non-transformable edge blocks\n");
|
75
|
+
#endif /* TRANSFORMS_SUPPORTED */
|
76
|
+
fprintf(stderr, "Switches for advanced users:\n");
|
77
|
+
fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n");
|
78
|
+
fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
|
79
|
+
fprintf(stderr, " -outfile name Specify name for output file\n");
|
80
|
+
fprintf(stderr, " -verbose or -debug Emit debug output\n");
|
81
|
+
fprintf(stderr, "Switches for wizards:\n");
|
82
|
+
#ifdef C_ARITH_CODING_SUPPORTED
|
83
|
+
fprintf(stderr, " -arithmetic Use arithmetic coding\n");
|
84
|
+
#endif
|
85
|
+
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
86
|
+
fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n");
|
87
|
+
#endif
|
88
|
+
exit(EXIT_FAILURE);
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
LOCAL(void)
|
93
|
+
select_transform (JXFORM_CODE transform)
|
94
|
+
/* Silly little routine to detect multiple transform options,
|
95
|
+
* which we can't handle.
|
96
|
+
*/
|
97
|
+
{
|
98
|
+
#if TRANSFORMS_SUPPORTED
|
99
|
+
if (transformoption.transform == JXFORM_NONE ||
|
100
|
+
transformoption.transform == transform) {
|
101
|
+
transformoption.transform = transform;
|
102
|
+
} else {
|
103
|
+
fprintf(stderr, "%s: can only do one image transformation at a time\n",
|
104
|
+
progname);
|
105
|
+
usage();
|
106
|
+
}
|
107
|
+
#else
|
108
|
+
fprintf(stderr, "%s: sorry, image transformation was not compiled\n",
|
109
|
+
progname);
|
110
|
+
exit(EXIT_FAILURE);
|
111
|
+
#endif
|
112
|
+
}
|
113
|
+
|
114
|
+
|
115
|
+
LOCAL(int)
|
116
|
+
parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
117
|
+
int last_file_arg_seen, boolean for_real)
|
118
|
+
/* Parse optional switches.
|
119
|
+
* Returns argv[] index of first file-name argument (== argc if none).
|
120
|
+
* Any file names with indexes <= last_file_arg_seen are ignored;
|
121
|
+
* they have presumably been processed in a previous iteration.
|
122
|
+
* (Pass 0 for last_file_arg_seen on the first or only iteration.)
|
123
|
+
* for_real is FALSE on the first (dummy) pass; we may skip any expensive
|
124
|
+
* processing.
|
125
|
+
*/
|
126
|
+
{
|
127
|
+
int argn;
|
128
|
+
char * arg;
|
129
|
+
boolean simple_progressive;
|
130
|
+
char * scansarg = NULL; /* saves -scans parm if any */
|
131
|
+
|
132
|
+
/* Set up default JPEG parameters. */
|
133
|
+
simple_progressive = FALSE;
|
134
|
+
outfilename = NULL;
|
135
|
+
copyoption = JCOPYOPT_DEFAULT;
|
136
|
+
transformoption.transform = JXFORM_NONE;
|
137
|
+
transformoption.trim = FALSE;
|
138
|
+
transformoption.perfect = FALSE;
|
139
|
+
transformoption.force_grayscale = FALSE;
|
140
|
+
transformoption.crop = FALSE;
|
141
|
+
cinfo->err->trace_level = 0;
|
142
|
+
|
143
|
+
/* Scan command line options, adjust parameters */
|
144
|
+
|
145
|
+
for (argn = 1; argn < argc; argn++) {
|
146
|
+
arg = argv[argn];
|
147
|
+
if (*arg != '-') {
|
148
|
+
/* Not a switch, must be a file name argument */
|
149
|
+
if (argn <= last_file_arg_seen) {
|
150
|
+
outfilename = NULL; /* -outfile applies to just one input file */
|
151
|
+
continue; /* ignore this name if previously processed */
|
152
|
+
}
|
153
|
+
break; /* else done parsing switches */
|
154
|
+
}
|
155
|
+
arg++; /* advance past switch marker character */
|
156
|
+
|
157
|
+
if (keymatch(arg, "arithmetic", 1)) {
|
158
|
+
/* Use arithmetic coding. */
|
159
|
+
#ifdef C_ARITH_CODING_SUPPORTED
|
160
|
+
cinfo->arith_code = TRUE;
|
161
|
+
#else
|
162
|
+
fprintf(stderr, "%s: sorry, arithmetic coding not supported\n",
|
163
|
+
progname);
|
164
|
+
exit(EXIT_FAILURE);
|
165
|
+
#endif
|
166
|
+
|
167
|
+
} else if (keymatch(arg, "copy", 2)) {
|
168
|
+
/* Select which extra markers to copy. */
|
169
|
+
if (++argn >= argc) /* advance to next argument */
|
170
|
+
usage();
|
171
|
+
if (keymatch(argv[argn], "none", 1)) {
|
172
|
+
copyoption = JCOPYOPT_NONE;
|
173
|
+
} else if (keymatch(argv[argn], "comments", 1)) {
|
174
|
+
copyoption = JCOPYOPT_COMMENTS;
|
175
|
+
} else if (keymatch(argv[argn], "all", 1)) {
|
176
|
+
copyoption = JCOPYOPT_ALL;
|
177
|
+
} else
|
178
|
+
usage();
|
179
|
+
|
180
|
+
} else if (keymatch(arg, "crop", 2)) {
|
181
|
+
/* Perform lossless cropping. */
|
182
|
+
#if TRANSFORMS_SUPPORTED
|
183
|
+
if (++argn >= argc) /* advance to next argument */
|
184
|
+
usage();
|
185
|
+
if (! jtransform_parse_crop_spec(&transformoption, argv[argn])) {
|
186
|
+
fprintf(stderr, "%s: bogus -crop argument '%s'\n",
|
187
|
+
progname, argv[argn]);
|
188
|
+
exit(EXIT_FAILURE);
|
189
|
+
}
|
190
|
+
#else
|
191
|
+
select_transform(JXFORM_NONE); /* force an error */
|
192
|
+
#endif
|
193
|
+
|
194
|
+
} else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
|
195
|
+
/* Enable debug printouts. */
|
196
|
+
/* On first -d, print version identification */
|
197
|
+
static boolean printed_version = FALSE;
|
198
|
+
|
199
|
+
if (! printed_version) {
|
200
|
+
fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n",
|
201
|
+
JVERSION, JCOPYRIGHT);
|
202
|
+
printed_version = TRUE;
|
203
|
+
}
|
204
|
+
cinfo->err->trace_level++;
|
205
|
+
|
206
|
+
} else if (keymatch(arg, "flip", 1)) {
|
207
|
+
/* Mirror left-right or top-bottom. */
|
208
|
+
if (++argn >= argc) /* advance to next argument */
|
209
|
+
usage();
|
210
|
+
if (keymatch(argv[argn], "horizontal", 1))
|
211
|
+
select_transform(JXFORM_FLIP_H);
|
212
|
+
else if (keymatch(argv[argn], "vertical", 1))
|
213
|
+
select_transform(JXFORM_FLIP_V);
|
214
|
+
else
|
215
|
+
usage();
|
216
|
+
|
217
|
+
} else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) {
|
218
|
+
/* Force to grayscale. */
|
219
|
+
#if TRANSFORMS_SUPPORTED
|
220
|
+
transformoption.force_grayscale = TRUE;
|
221
|
+
#else
|
222
|
+
select_transform(JXFORM_NONE); /* force an error */
|
223
|
+
#endif
|
224
|
+
|
225
|
+
} else if (keymatch(arg, "maxmemory", 3)) {
|
226
|
+
/* Maximum memory in Kb (or Mb with 'm'). */
|
227
|
+
long lval;
|
228
|
+
char ch = 'x';
|
229
|
+
|
230
|
+
if (++argn >= argc) /* advance to next argument */
|
231
|
+
usage();
|
232
|
+
if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
|
233
|
+
usage();
|
234
|
+
if (ch == 'm' || ch == 'M')
|
235
|
+
lval *= 1000L;
|
236
|
+
cinfo->mem->max_memory_to_use = lval * 1000L;
|
237
|
+
|
238
|
+
} else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
|
239
|
+
/* Enable entropy parm optimization. */
|
240
|
+
#ifdef ENTROPY_OPT_SUPPORTED
|
241
|
+
cinfo->optimize_coding = TRUE;
|
242
|
+
#else
|
243
|
+
fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n",
|
244
|
+
progname);
|
245
|
+
exit(EXIT_FAILURE);
|
246
|
+
#endif
|
247
|
+
|
248
|
+
} else if (keymatch(arg, "outfile", 4)) {
|
249
|
+
/* Set output file name. */
|
250
|
+
if (++argn >= argc) /* advance to next argument */
|
251
|
+
usage();
|
252
|
+
outfilename = argv[argn]; /* save it away for later use */
|
253
|
+
|
254
|
+
} else if (keymatch(arg, "perfect", 2)) {
|
255
|
+
/* Fail if there is any partial edge MCUs that the transform can't
|
256
|
+
* handle. */
|
257
|
+
transformoption.perfect = TRUE;
|
258
|
+
|
259
|
+
} else if (keymatch(arg, "progressive", 2)) {
|
260
|
+
/* Select simple progressive mode. */
|
261
|
+
#ifdef C_PROGRESSIVE_SUPPORTED
|
262
|
+
simple_progressive = TRUE;
|
263
|
+
/* We must postpone execution until num_components is known. */
|
264
|
+
#else
|
265
|
+
fprintf(stderr, "%s: sorry, progressive output was not compiled\n",
|
266
|
+
progname);
|
267
|
+
exit(EXIT_FAILURE);
|
268
|
+
#endif
|
269
|
+
|
270
|
+
} else if (keymatch(arg, "restart", 1)) {
|
271
|
+
/* Restart interval in MCU rows (or in MCUs with 'b'). */
|
272
|
+
long lval;
|
273
|
+
char ch = 'x';
|
274
|
+
|
275
|
+
if (++argn >= argc) /* advance to next argument */
|
276
|
+
usage();
|
277
|
+
if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
|
278
|
+
usage();
|
279
|
+
if (lval < 0 || lval > 65535L)
|
280
|
+
usage();
|
281
|
+
if (ch == 'b' || ch == 'B') {
|
282
|
+
cinfo->restart_interval = (unsigned int) lval;
|
283
|
+
cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */
|
284
|
+
} else {
|
285
|
+
cinfo->restart_in_rows = (int) lval;
|
286
|
+
/* restart_interval will be computed during startup */
|
287
|
+
}
|
288
|
+
|
289
|
+
} else if (keymatch(arg, "rotate", 2)) {
|
290
|
+
/* Rotate 90, 180, or 270 degrees (measured clockwise). */
|
291
|
+
if (++argn >= argc) /* advance to next argument */
|
292
|
+
usage();
|
293
|
+
if (keymatch(argv[argn], "90", 2))
|
294
|
+
select_transform(JXFORM_ROT_90);
|
295
|
+
else if (keymatch(argv[argn], "180", 3))
|
296
|
+
select_transform(JXFORM_ROT_180);
|
297
|
+
else if (keymatch(argv[argn], "270", 3))
|
298
|
+
select_transform(JXFORM_ROT_270);
|
299
|
+
else
|
300
|
+
usage();
|
301
|
+
|
302
|
+
} else if (keymatch(arg, "scans", 1)) {
|
303
|
+
/* Set scan script. */
|
304
|
+
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
305
|
+
if (++argn >= argc) /* advance to next argument */
|
306
|
+
usage();
|
307
|
+
scansarg = argv[argn];
|
308
|
+
/* We must postpone reading the file in case -progressive appears. */
|
309
|
+
#else
|
310
|
+
fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n",
|
311
|
+
progname);
|
312
|
+
exit(EXIT_FAILURE);
|
313
|
+
#endif
|
314
|
+
|
315
|
+
} else if (keymatch(arg, "transpose", 1)) {
|
316
|
+
/* Transpose (across UL-to-LR axis). */
|
317
|
+
select_transform(JXFORM_TRANSPOSE);
|
318
|
+
|
319
|
+
} else if (keymatch(arg, "transverse", 6)) {
|
320
|
+
/* Transverse transpose (across UR-to-LL axis). */
|
321
|
+
select_transform(JXFORM_TRANSVERSE);
|
322
|
+
|
323
|
+
} else if (keymatch(arg, "trim", 3)) {
|
324
|
+
/* Trim off any partial edge MCUs that the transform can't handle. */
|
325
|
+
transformoption.trim = TRUE;
|
326
|
+
|
327
|
+
} else {
|
328
|
+
usage(); /* bogus switch */
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
/* Post-switch-scanning cleanup */
|
333
|
+
|
334
|
+
if (for_real) {
|
335
|
+
|
336
|
+
#ifdef C_PROGRESSIVE_SUPPORTED
|
337
|
+
if (simple_progressive) /* process -progressive; -scans can override */
|
338
|
+
jpeg_simple_progression(cinfo);
|
339
|
+
#endif
|
340
|
+
|
341
|
+
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
342
|
+
if (scansarg != NULL) /* process -scans if it was present */
|
343
|
+
if (! read_scan_script(cinfo, scansarg))
|
344
|
+
usage();
|
345
|
+
#endif
|
346
|
+
}
|
347
|
+
|
348
|
+
return argn; /* return index of next arg (file name) */
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
/*
|
353
|
+
* The main program.
|
354
|
+
*/
|
355
|
+
|
356
|
+
int
|
357
|
+
main (int argc, char **argv)
|
358
|
+
{
|
359
|
+
struct jpeg_decompress_struct srcinfo;
|
360
|
+
struct jpeg_compress_struct dstinfo;
|
361
|
+
struct jpeg_error_mgr jsrcerr, jdsterr;
|
362
|
+
#ifdef PROGRESS_REPORT
|
363
|
+
struct cdjpeg_progress_mgr progress;
|
364
|
+
#endif
|
365
|
+
jvirt_barray_ptr * src_coef_arrays;
|
366
|
+
jvirt_barray_ptr * dst_coef_arrays;
|
367
|
+
int file_index;
|
368
|
+
/* We assume all-in-memory processing and can therefore use only a
|
369
|
+
* single file pointer for sequential input and output operation.
|
370
|
+
*/
|
371
|
+
FILE * fp;
|
372
|
+
|
373
|
+
/* On Mac, fetch a command line. */
|
374
|
+
#ifdef USE_CCOMMAND
|
375
|
+
argc = ccommand(&argv);
|
376
|
+
#endif
|
377
|
+
|
378
|
+
progname = argv[0];
|
379
|
+
if (progname == NULL || progname[0] == 0)
|
380
|
+
progname = "jpegtran"; /* in case C library doesn't provide it */
|
381
|
+
|
382
|
+
/* Initialize the JPEG decompression object with default error handling. */
|
383
|
+
srcinfo.err = jpeg_std_error(&jsrcerr);
|
384
|
+
jpeg_create_decompress(&srcinfo);
|
385
|
+
/* Initialize the JPEG compression object with default error handling. */
|
386
|
+
dstinfo.err = jpeg_std_error(&jdsterr);
|
387
|
+
jpeg_create_compress(&dstinfo);
|
388
|
+
|
389
|
+
/* Now safe to enable signal catcher.
|
390
|
+
* Note: we assume only the decompression object will have virtual arrays.
|
391
|
+
*/
|
392
|
+
#ifdef NEED_SIGNAL_CATCHER
|
393
|
+
enable_signal_catcher((j_common_ptr) &srcinfo);
|
394
|
+
#endif
|
395
|
+
|
396
|
+
/* Scan command line to find file names.
|
397
|
+
* It is convenient to use just one switch-parsing routine, but the switch
|
398
|
+
* values read here are mostly ignored; we will rescan the switches after
|
399
|
+
* opening the input file. Also note that most of the switches affect the
|
400
|
+
* destination JPEG object, so we parse into that and then copy over what
|
401
|
+
* needs to affects the source too.
|
402
|
+
*/
|
403
|
+
|
404
|
+
file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE);
|
405
|
+
jsrcerr.trace_level = jdsterr.trace_level;
|
406
|
+
srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use;
|
407
|
+
|
408
|
+
#ifdef TWO_FILE_COMMANDLINE
|
409
|
+
/* Must have either -outfile switch or explicit output file name */
|
410
|
+
if (outfilename == NULL) {
|
411
|
+
if (file_index != argc-2) {
|
412
|
+
fprintf(stderr, "%s: must name one input and one output file\n",
|
413
|
+
progname);
|
414
|
+
usage();
|
415
|
+
}
|
416
|
+
outfilename = argv[file_index+1];
|
417
|
+
} else {
|
418
|
+
if (file_index != argc-1) {
|
419
|
+
fprintf(stderr, "%s: must name one input and one output file\n",
|
420
|
+
progname);
|
421
|
+
usage();
|
422
|
+
}
|
423
|
+
}
|
424
|
+
#else
|
425
|
+
/* Unix style: expect zero or one file name */
|
426
|
+
if (file_index < argc-1) {
|
427
|
+
fprintf(stderr, "%s: only one input file\n", progname);
|
428
|
+
usage();
|
429
|
+
}
|
430
|
+
#endif /* TWO_FILE_COMMANDLINE */
|
431
|
+
|
432
|
+
/* Open the input file. */
|
433
|
+
if (file_index < argc) {
|
434
|
+
if ((fp = fopen(argv[file_index], READ_BINARY)) == NULL) {
|
435
|
+
fprintf(stderr, "%s: can't open %s for reading\n", progname, argv[file_index]);
|
436
|
+
exit(EXIT_FAILURE);
|
437
|
+
}
|
438
|
+
} else {
|
439
|
+
/* default input file is stdin */
|
440
|
+
fp = read_stdin();
|
441
|
+
}
|
442
|
+
|
443
|
+
#ifdef PROGRESS_REPORT
|
444
|
+
start_progress_monitor((j_common_ptr) &dstinfo, &progress);
|
445
|
+
#endif
|
446
|
+
|
447
|
+
/* Specify data source for decompression */
|
448
|
+
jpeg_stdio_src(&srcinfo, fp);
|
449
|
+
|
450
|
+
/* Enable saving of extra markers that we want to copy */
|
451
|
+
jcopy_markers_setup(&srcinfo, copyoption);
|
452
|
+
|
453
|
+
/* Read file header */
|
454
|
+
(void) jpeg_read_header(&srcinfo, TRUE);
|
455
|
+
|
456
|
+
/* Any space needed by a transform option must be requested before
|
457
|
+
* jpeg_read_coefficients so that memory allocation will be done right.
|
458
|
+
*/
|
459
|
+
#if TRANSFORMS_SUPPORTED
|
460
|
+
/* Fails right away if -perfect is given and transformation is not perfect.
|
461
|
+
*/
|
462
|
+
if (transformoption.perfect &&
|
463
|
+
!jtransform_perfect_transform(srcinfo.image_width, srcinfo.image_height,
|
464
|
+
srcinfo.max_h_samp_factor * DCTSIZE, srcinfo.max_v_samp_factor * DCTSIZE,
|
465
|
+
transformoption.transform)) {
|
466
|
+
fprintf(stderr, "%s: transformation is not perfect\n", progname);
|
467
|
+
exit(EXIT_FAILURE);
|
468
|
+
}
|
469
|
+
jtransform_request_workspace(&srcinfo, &transformoption);
|
470
|
+
#endif
|
471
|
+
|
472
|
+
/* Read source file as DCT coefficients */
|
473
|
+
src_coef_arrays = jpeg_read_coefficients(&srcinfo);
|
474
|
+
|
475
|
+
/* Initialize destination compression parameters from source values */
|
476
|
+
jpeg_copy_critical_parameters(&srcinfo, &dstinfo);
|
477
|
+
|
478
|
+
/* Adjust destination parameters if required by transform options;
|
479
|
+
* also find out which set of coefficient arrays will hold the output.
|
480
|
+
*/
|
481
|
+
#if TRANSFORMS_SUPPORTED
|
482
|
+
dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo,
|
483
|
+
src_coef_arrays,
|
484
|
+
&transformoption);
|
485
|
+
#else
|
486
|
+
dst_coef_arrays = src_coef_arrays;
|
487
|
+
#endif
|
488
|
+
|
489
|
+
/* Close input file, if we opened it.
|
490
|
+
* Note: we assume that jpeg_read_coefficients consumed all input
|
491
|
+
* until JPEG_REACHED_EOI, and that jpeg_finish_decompress will
|
492
|
+
* only consume more while (! cinfo->inputctl->eoi_reached).
|
493
|
+
* We cannot call jpeg_finish_decompress here since we still need the
|
494
|
+
* virtual arrays allocated from the source object for processing.
|
495
|
+
*/
|
496
|
+
if (fp != stdin)
|
497
|
+
fclose(fp);
|
498
|
+
|
499
|
+
/* Open the output file. */
|
500
|
+
if (outfilename != NULL) {
|
501
|
+
if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) {
|
502
|
+
fprintf(stderr, "%s: can't open %s for writing\n", progname, outfilename);
|
503
|
+
exit(EXIT_FAILURE);
|
504
|
+
}
|
505
|
+
} else {
|
506
|
+
/* default output file is stdout */
|
507
|
+
fp = write_stdout();
|
508
|
+
}
|
509
|
+
|
510
|
+
/* Adjust default compression parameters by re-parsing the options */
|
511
|
+
file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE);
|
512
|
+
|
513
|
+
/* Specify data destination for compression */
|
514
|
+
jpeg_stdio_dest(&dstinfo, fp);
|
515
|
+
|
516
|
+
/* Start compressor (note no image data is actually written here) */
|
517
|
+
jpeg_write_coefficients(&dstinfo, dst_coef_arrays);
|
518
|
+
|
519
|
+
/* Copy to the output file any extra markers that we want to preserve */
|
520
|
+
jcopy_markers_execute(&srcinfo, &dstinfo, copyoption);
|
521
|
+
|
522
|
+
/* Execute image transformation, if any */
|
523
|
+
#if TRANSFORMS_SUPPORTED
|
524
|
+
jtransform_execute_transformation(&srcinfo, &dstinfo,
|
525
|
+
src_coef_arrays,
|
526
|
+
&transformoption);
|
527
|
+
#endif
|
528
|
+
|
529
|
+
/* Finish compression and release memory */
|
530
|
+
jpeg_finish_compress(&dstinfo);
|
531
|
+
jpeg_destroy_compress(&dstinfo);
|
532
|
+
(void) jpeg_finish_decompress(&srcinfo);
|
533
|
+
jpeg_destroy_decompress(&srcinfo);
|
534
|
+
|
535
|
+
/* Close output file, if we opened it */
|
536
|
+
if (fp != stdout)
|
537
|
+
fclose(fp);
|
538
|
+
|
539
|
+
#ifdef PROGRESS_REPORT
|
540
|
+
end_progress_monitor((j_common_ptr) &dstinfo);
|
541
|
+
#endif
|
542
|
+
|
543
|
+
/* All done. */
|
544
|
+
exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS);
|
545
|
+
return 0; /* suppress no-return-value warnings */
|
546
|
+
}
|