isbn 2.0.4 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/{README → README.md} +5 -11
- data/Rakefile +20 -14
- data/isbn.gemspec +23 -0
- data/lib/isbn.rb +2 -0
- data/test/isbn_spec.rb +1 -1
- metadata +29 -316
- data/VERSION +0 -1
- data/src/gocr-0.48/.cvsignore +0 -6
- data/src/gocr-0.48/AUTHORS +0 -7
- data/src/gocr-0.48/BUGS +0 -55
- data/src/gocr-0.48/CREDITS +0 -17
- data/src/gocr-0.48/HISTORY +0 -243
- data/src/gocr-0.48/INSTALL +0 -83
- data/src/gocr-0.48/Makefile +0 -193
- data/src/gocr-0.48/Makefile.in +0 -193
- data/src/gocr-0.48/README +0 -165
- data/src/gocr-0.48/READMEde.txt +0 -80
- data/src/gocr-0.48/REMARK.txt +0 -18
- data/src/gocr-0.48/REVIEW +0 -538
- data/src/gocr-0.48/TODO +0 -65
- data/src/gocr-0.48/bin/.cvsignore +0 -2
- data/src/gocr-0.48/bin/create_db +0 -38
- data/src/gocr-0.48/bin/gocr.tcl +0 -527
- data/src/gocr-0.48/bin/gocr_chk.sh +0 -44
- data/src/gocr-0.48/configure +0 -4689
- data/src/gocr-0.48/configure.in +0 -71
- data/src/gocr-0.48/doc/.#Makefile.1.6 +0 -39
- data/src/gocr-0.48/doc/.cvsignore +0 -2
- data/src/gocr-0.48/doc/Makefile +0 -39
- data/src/gocr-0.48/doc/Makefile.in +0 -39
- data/src/gocr-0.48/doc/example.dtd +0 -53
- data/src/gocr-0.48/doc/example.xml +0 -21
- data/src/gocr-0.48/doc/examples.txt +0 -67
- data/src/gocr-0.48/doc/gocr.html +0 -578
- data/src/gocr-0.48/doc/unicode.txt +0 -57
- data/src/gocr-0.48/examples/.#Makefile.1.22 +0 -166
- data/src/gocr-0.48/examples/4x6.png +0 -0
- data/src/gocr-0.48/examples/4x6.txt +0 -2
- data/src/gocr-0.48/examples/5x7.png +0 -0
- data/src/gocr-0.48/examples/5x7.png.txt +0 -2
- data/src/gocr-0.48/examples/5x8.png +0 -0
- data/src/gocr-0.48/examples/5x8.png.txt +0 -2
- data/src/gocr-0.48/examples/Makefile +0 -166
- data/src/gocr-0.48/examples/color.fig +0 -20
- data/src/gocr-0.48/examples/ex.fig +0 -16
- data/src/gocr-0.48/examples/font.tex +0 -22
- data/src/gocr-0.48/examples/font1.tex +0 -46
- data/src/gocr-0.48/examples/font2.fig +0 -27
- data/src/gocr-0.48/examples/font_nw.tex +0 -24
- data/src/gocr-0.48/examples/handwrt1.jpg +0 -0
- data/src/gocr-0.48/examples/handwrt1.txt +0 -10
- data/src/gocr-0.48/examples/inverse.fig +0 -20
- 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 +0 -4
- data/src/gocr-0.48/examples/ocr-a.png +0 -0
- data/src/gocr-0.48/examples/ocr-a.txt +0 -6
- data/src/gocr-0.48/examples/ocr-b.png +0 -0
- data/src/gocr-0.48/examples/ocr-b.png.txt +0 -4
- data/src/gocr-0.48/examples/polish.tex +0 -28
- data/src/gocr-0.48/examples/rotate45.fig +0 -14
- data/src/gocr-0.48/examples/score +0 -36
- data/src/gocr-0.48/examples/text.tex +0 -28
- data/src/gocr-0.48/gpl.html +0 -537
- data/src/gocr-0.48/include/.cvsignore +0 -2
- data/src/gocr-0.48/include/config.h +0 -36
- data/src/gocr-0.48/include/config.h.in +0 -36
- data/src/gocr-0.48/include/version.h +0 -2
- data/src/gocr-0.48/install-sh +0 -3
- data/src/gocr-0.48/make.bat +0 -57
- data/src/gocr-0.48/man/.cvsignore +0 -2
- data/src/gocr-0.48/man/Makefile +0 -29
- data/src/gocr-0.48/man/Makefile.in +0 -29
- data/src/gocr-0.48/man/man1/gocr.1 +0 -166
- data/src/gocr-0.48/src/.cvsignore +0 -4
- data/src/gocr-0.48/src/Makefile +0 -132
- data/src/gocr-0.48/src/Makefile.in +0 -132
- data/src/gocr-0.48/src/amiga.h +0 -31
- data/src/gocr-0.48/src/barcode.c +0 -846
- data/src/gocr-0.48/src/barcode.c.orig +0 -593
- data/src/gocr-0.48/src/barcode.h +0 -11
- data/src/gocr-0.48/src/box.c +0 -372
- data/src/gocr-0.48/src/database.c +0 -462
- data/src/gocr-0.48/src/detect.c +0 -943
- data/src/gocr-0.48/src/gocr.c +0 -373
- data/src/gocr-0.48/src/gocr.h +0 -288
- data/src/gocr-0.48/src/jconv.c +0 -168
- data/src/gocr-0.48/src/job.c +0 -84
- data/src/gocr-0.48/src/lines.c +0 -350
- data/src/gocr-0.48/src/list.c +0 -334
- data/src/gocr-0.48/src/list.h +0 -90
- data/src/gocr-0.48/src/ocr0.c +0 -6756
- data/src/gocr-0.48/src/ocr0.h +0 -63
- data/src/gocr-0.48/src/ocr0n.c +0 -1475
- data/src/gocr-0.48/src/ocr1.c +0 -85
- data/src/gocr-0.48/src/ocr1.h +0 -3
- data/src/gocr-0.48/src/otsu.c +0 -289
- data/src/gocr-0.48/src/otsu.h +0 -23
- data/src/gocr-0.48/src/output.c +0 -289
- data/src/gocr-0.48/src/output.h +0 -37
- data/src/gocr-0.48/src/pcx.c +0 -153
- data/src/gocr-0.48/src/pcx.h +0 -9
- data/src/gocr-0.48/src/pgm2asc.c +0 -2893
- data/src/gocr-0.48/src/pgm2asc.h +0 -105
- data/src/gocr-0.48/src/pixel.c +0 -537
- data/src/gocr-0.48/src/pnm.c +0 -533
- data/src/gocr-0.48/src/pnm.h +0 -35
- data/src/gocr-0.48/src/progress.c +0 -87
- data/src/gocr-0.48/src/progress.h +0 -42
- data/src/gocr-0.48/src/remove.c +0 -703
- data/src/gocr-0.48/src/tga.c +0 -87
- data/src/gocr-0.48/src/tga.h +0 -6
- data/src/gocr-0.48/src/unicode.c +0 -1314
- data/src/gocr-0.48/src/unicode.h +0 -1257
- data/src/jpeg-7/Makefile.am +0 -133
- data/src/jpeg-7/Makefile.in +0 -1089
- data/src/jpeg-7/README +0 -322
- data/src/jpeg-7/aclocal.m4 +0 -8990
- data/src/jpeg-7/ansi2knr.1 +0 -36
- data/src/jpeg-7/ansi2knr.c +0 -739
- data/src/jpeg-7/cderror.h +0 -132
- data/src/jpeg-7/cdjpeg.c +0 -181
- data/src/jpeg-7/cdjpeg.h +0 -187
- data/src/jpeg-7/change.log +0 -270
- data/src/jpeg-7/cjpeg.1 +0 -325
- data/src/jpeg-7/cjpeg.c +0 -616
- data/src/jpeg-7/ckconfig.c +0 -402
- data/src/jpeg-7/coderules.txt +0 -118
- data/src/jpeg-7/config.guess +0 -1561
- data/src/jpeg-7/config.sub +0 -1686
- data/src/jpeg-7/configure +0 -17139
- data/src/jpeg-7/configure.ac +0 -317
- data/src/jpeg-7/depcomp +0 -630
- data/src/jpeg-7/djpeg.1 +0 -251
- data/src/jpeg-7/djpeg.c +0 -617
- data/src/jpeg-7/example.c +0 -433
- data/src/jpeg-7/filelist.txt +0 -215
- data/src/jpeg-7/install-sh +0 -520
- data/src/jpeg-7/install.txt +0 -1097
- data/src/jpeg-7/jaricom.c +0 -148
- data/src/jpeg-7/jcapimin.c +0 -282
- data/src/jpeg-7/jcapistd.c +0 -161
- data/src/jpeg-7/jcarith.c +0 -921
- data/src/jpeg-7/jccoefct.c +0 -453
- data/src/jpeg-7/jccolor.c +0 -459
- data/src/jpeg-7/jcdctmgr.c +0 -482
- data/src/jpeg-7/jchuff.c +0 -1612
- data/src/jpeg-7/jcinit.c +0 -65
- data/src/jpeg-7/jcmainct.c +0 -293
- data/src/jpeg-7/jcmarker.c +0 -667
- data/src/jpeg-7/jcmaster.c +0 -770
- data/src/jpeg-7/jcomapi.c +0 -106
- data/src/jpeg-7/jconfig.bcc +0 -48
- data/src/jpeg-7/jconfig.cfg +0 -45
- data/src/jpeg-7/jconfig.dj +0 -38
- data/src/jpeg-7/jconfig.mac +0 -43
- data/src/jpeg-7/jconfig.manx +0 -43
- data/src/jpeg-7/jconfig.mc6 +0 -52
- data/src/jpeg-7/jconfig.sas +0 -43
- data/src/jpeg-7/jconfig.st +0 -42
- data/src/jpeg-7/jconfig.txt +0 -155
- data/src/jpeg-7/jconfig.vc +0 -45
- data/src/jpeg-7/jconfig.vms +0 -37
- data/src/jpeg-7/jconfig.wat +0 -38
- data/src/jpeg-7/jcparam.c +0 -632
- data/src/jpeg-7/jcprepct.c +0 -358
- data/src/jpeg-7/jcsample.c +0 -545
- data/src/jpeg-7/jctrans.c +0 -381
- data/src/jpeg-7/jdapimin.c +0 -396
- data/src/jpeg-7/jdapistd.c +0 -275
- data/src/jpeg-7/jdarith.c +0 -762
- data/src/jpeg-7/jdatadst.c +0 -151
- data/src/jpeg-7/jdatasrc.c +0 -212
- data/src/jpeg-7/jdcoefct.c +0 -736
- data/src/jpeg-7/jdcolor.c +0 -396
- data/src/jpeg-7/jdct.h +0 -393
- data/src/jpeg-7/jddctmgr.c +0 -382
- data/src/jpeg-7/jdhuff.c +0 -1309
- data/src/jpeg-7/jdinput.c +0 -384
- data/src/jpeg-7/jdmainct.c +0 -512
- data/src/jpeg-7/jdmarker.c +0 -1360
- data/src/jpeg-7/jdmaster.c +0 -663
- data/src/jpeg-7/jdmerge.c +0 -400
- data/src/jpeg-7/jdpostct.c +0 -290
- data/src/jpeg-7/jdsample.c +0 -361
- data/src/jpeg-7/jdtrans.c +0 -136
- data/src/jpeg-7/jerror.c +0 -252
- data/src/jpeg-7/jerror.h +0 -304
- data/src/jpeg-7/jfdctflt.c +0 -174
- data/src/jpeg-7/jfdctfst.c +0 -230
- data/src/jpeg-7/jfdctint.c +0 -4348
- data/src/jpeg-7/jidctflt.c +0 -242
- data/src/jpeg-7/jidctfst.c +0 -368
- data/src/jpeg-7/jidctint.c +0 -5137
- data/src/jpeg-7/jinclude.h +0 -91
- data/src/jpeg-7/jmemansi.c +0 -167
- data/src/jpeg-7/jmemdos.c +0 -638
- data/src/jpeg-7/jmemdosa.asm +0 -379
- data/src/jpeg-7/jmemmac.c +0 -289
- data/src/jpeg-7/jmemmgr.c +0 -1118
- data/src/jpeg-7/jmemname.c +0 -276
- data/src/jpeg-7/jmemnobs.c +0 -109
- data/src/jpeg-7/jmemsys.h +0 -198
- data/src/jpeg-7/jmorecfg.h +0 -369
- data/src/jpeg-7/jpegint.h +0 -395
- data/src/jpeg-7/jpeglib.h +0 -1135
- data/src/jpeg-7/jpegtran.1 +0 -272
- data/src/jpeg-7/jpegtran.c +0 -546
- data/src/jpeg-7/jquant1.c +0 -856
- data/src/jpeg-7/jquant2.c +0 -1310
- data/src/jpeg-7/jutils.c +0 -179
- data/src/jpeg-7/jversion.h +0 -14
- data/src/jpeg-7/libjpeg.map +0 -4
- data/src/jpeg-7/libjpeg.txt +0 -3067
- data/src/jpeg-7/ltmain.sh +0 -8406
- data/src/jpeg-7/makcjpeg.st +0 -36
- data/src/jpeg-7/makdjpeg.st +0 -36
- data/src/jpeg-7/makeadsw.vc6 +0 -77
- data/src/jpeg-7/makeasln.vc9 +0 -33
- data/src/jpeg-7/makecdep.vc6 +0 -82
- data/src/jpeg-7/makecdsp.vc6 +0 -130
- data/src/jpeg-7/makecmak.vc6 +0 -159
- data/src/jpeg-7/makecvcp.vc9 +0 -186
- data/src/jpeg-7/makeddep.vc6 +0 -82
- data/src/jpeg-7/makeddsp.vc6 +0 -130
- data/src/jpeg-7/makedmak.vc6 +0 -159
- data/src/jpeg-7/makedvcp.vc9 +0 -186
- data/src/jpeg-7/makefile.ansi +0 -220
- data/src/jpeg-7/makefile.bcc +0 -291
- data/src/jpeg-7/makefile.dj +0 -226
- data/src/jpeg-7/makefile.manx +0 -220
- data/src/jpeg-7/makefile.mc6 +0 -255
- data/src/jpeg-7/makefile.mms +0 -224
- data/src/jpeg-7/makefile.sas +0 -258
- data/src/jpeg-7/makefile.unix +0 -234
- data/src/jpeg-7/makefile.vc +0 -217
- data/src/jpeg-7/makefile.vms +0 -142
- data/src/jpeg-7/makefile.wat +0 -239
- data/src/jpeg-7/makejdep.vc6 +0 -423
- data/src/jpeg-7/makejdsp.vc6 +0 -285
- data/src/jpeg-7/makejdsw.vc6 +0 -29
- data/src/jpeg-7/makejmak.vc6 +0 -425
- data/src/jpeg-7/makejsln.vc9 +0 -17
- data/src/jpeg-7/makejvcp.vc9 +0 -328
- data/src/jpeg-7/makeproj.mac +0 -213
- data/src/jpeg-7/makerdep.vc6 +0 -6
- data/src/jpeg-7/makerdsp.vc6 +0 -78
- data/src/jpeg-7/makermak.vc6 +0 -110
- data/src/jpeg-7/makervcp.vc9 +0 -133
- data/src/jpeg-7/maketdep.vc6 +0 -43
- data/src/jpeg-7/maketdsp.vc6 +0 -122
- data/src/jpeg-7/maketmak.vc6 +0 -131
- data/src/jpeg-7/maketvcp.vc9 +0 -178
- data/src/jpeg-7/makewdep.vc6 +0 -6
- data/src/jpeg-7/makewdsp.vc6 +0 -78
- data/src/jpeg-7/makewmak.vc6 +0 -110
- data/src/jpeg-7/makewvcp.vc9 +0 -133
- data/src/jpeg-7/makljpeg.st +0 -68
- data/src/jpeg-7/maktjpeg.st +0 -30
- data/src/jpeg-7/makvms.opt +0 -4
- data/src/jpeg-7/missing +0 -376
- data/src/jpeg-7/rdbmp.c +0 -439
- data/src/jpeg-7/rdcolmap.c +0 -253
- data/src/jpeg-7/rdgif.c +0 -38
- data/src/jpeg-7/rdjpgcom.1 +0 -63
- data/src/jpeg-7/rdjpgcom.c +0 -515
- data/src/jpeg-7/rdppm.c +0 -459
- data/src/jpeg-7/rdrle.c +0 -387
- data/src/jpeg-7/rdswitch.c +0 -365
- data/src/jpeg-7/rdtarga.c +0 -500
- data/src/jpeg-7/structure.txt +0 -945
- data/src/jpeg-7/testimg.bmp +0 -0
- data/src/jpeg-7/testimg.jpg +0 -0
- data/src/jpeg-7/testimg.ppm +0 -4
- 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 +0 -1533
- data/src/jpeg-7/transupp.h +0 -205
- data/src/jpeg-7/usage.txt +0 -605
- data/src/jpeg-7/wizard.txt +0 -211
- data/src/jpeg-7/wrbmp.c +0 -442
- data/src/jpeg-7/wrgif.c +0 -399
- data/src/jpeg-7/wrjpgcom.1 +0 -103
- data/src/jpeg-7/wrjpgcom.c +0 -583
- data/src/jpeg-7/wrppm.c +0 -269
- data/src/jpeg-7/wrrle.c +0 -305
- data/src/jpeg-7/wrtarga.c +0 -253
data/src/jpeg-7/djpeg.1
DELETED
@@ -1,251 +0,0 @@
|
|
1
|
-
.TH DJPEG 1 "28 March 2009"
|
2
|
-
.SH NAME
|
3
|
-
djpeg \- decompress a JPEG file to an image file
|
4
|
-
.SH SYNOPSIS
|
5
|
-
.B djpeg
|
6
|
-
[
|
7
|
-
.I options
|
8
|
-
]
|
9
|
-
[
|
10
|
-
.I filename
|
11
|
-
]
|
12
|
-
.LP
|
13
|
-
.SH DESCRIPTION
|
14
|
-
.LP
|
15
|
-
.B djpeg
|
16
|
-
decompresses the named JPEG file, or the standard input if no file is named,
|
17
|
-
and produces an image file on the standard output. PBMPLUS (PPM/PGM), BMP,
|
18
|
-
GIF, Targa, or RLE (Utah Raster Toolkit) output format can be selected.
|
19
|
-
(RLE is supported only if the URT library is available.)
|
20
|
-
.SH OPTIONS
|
21
|
-
All switch names may be abbreviated; for example,
|
22
|
-
.B \-grayscale
|
23
|
-
may be written
|
24
|
-
.B \-gray
|
25
|
-
or
|
26
|
-
.BR \-gr .
|
27
|
-
Most of the "basic" switches can be abbreviated to as little as one letter.
|
28
|
-
Upper and lower case are equivalent (thus
|
29
|
-
.B \-BMP
|
30
|
-
is the same as
|
31
|
-
.BR \-bmp ).
|
32
|
-
British spellings are also accepted (e.g.,
|
33
|
-
.BR \-greyscale ),
|
34
|
-
though for brevity these are not mentioned below.
|
35
|
-
.PP
|
36
|
-
The basic switches are:
|
37
|
-
.TP
|
38
|
-
.BI \-colors " N"
|
39
|
-
Reduce image to at most N colors. This reduces the number of colors used in
|
40
|
-
the output image, so that it can be displayed on a colormapped display or
|
41
|
-
stored in a colormapped file format. For example, if you have an 8-bit
|
42
|
-
display, you'd need to reduce to 256 or fewer colors.
|
43
|
-
.TP
|
44
|
-
.BI \-quantize " N"
|
45
|
-
Same as
|
46
|
-
.BR \-colors .
|
47
|
-
.B \-colors
|
48
|
-
is the recommended name,
|
49
|
-
.B \-quantize
|
50
|
-
is provided only for backwards compatibility.
|
51
|
-
.TP
|
52
|
-
.B \-fast
|
53
|
-
Select recommended processing options for fast, low quality output. (The
|
54
|
-
default options are chosen for highest quality output.) Currently, this is
|
55
|
-
equivalent to \fB\-dct fast \-nosmooth \-onepass \-dither ordered\fR.
|
56
|
-
.TP
|
57
|
-
.B \-grayscale
|
58
|
-
Force gray-scale output even if JPEG file is color. Useful for viewing on
|
59
|
-
monochrome displays; also,
|
60
|
-
.B djpeg
|
61
|
-
runs noticeably faster in this mode.
|
62
|
-
.TP
|
63
|
-
.BI \-scale " M/N"
|
64
|
-
Scale the output image by a factor M/N. Currently supported scale factors are
|
65
|
-
M/8 with all M from 1 to 16. If the /N part is omitted, then M specifies the
|
66
|
-
DCT scaled size to be applied on the given input, which is currently
|
67
|
-
equivalent to M/8 scaling, since the source DCT size is currently always 8.
|
68
|
-
Scaling is handy if the image is larger than your screen; also,
|
69
|
-
.B djpeg
|
70
|
-
runs much faster when scaling down the output.
|
71
|
-
.TP
|
72
|
-
.B \-bmp
|
73
|
-
Select BMP output format (Windows flavor). 8-bit colormapped format is
|
74
|
-
emitted if
|
75
|
-
.B \-colors
|
76
|
-
or
|
77
|
-
.B \-grayscale
|
78
|
-
is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color
|
79
|
-
format is emitted.
|
80
|
-
.TP
|
81
|
-
.B \-gif
|
82
|
-
Select GIF output format. Since GIF does not support more than 256 colors,
|
83
|
-
.B \-colors 256
|
84
|
-
is assumed (unless you specify a smaller number of colors).
|
85
|
-
.TP
|
86
|
-
.B \-os2
|
87
|
-
Select BMP output format (OS/2 1.x flavor). 8-bit colormapped format is
|
88
|
-
emitted if
|
89
|
-
.B \-colors
|
90
|
-
or
|
91
|
-
.B \-grayscale
|
92
|
-
is specified, or if the JPEG file is gray-scale; otherwise, 24-bit full-color
|
93
|
-
format is emitted.
|
94
|
-
.TP
|
95
|
-
.B \-pnm
|
96
|
-
Select PBMPLUS (PPM/PGM) output format (this is the default format).
|
97
|
-
PGM is emitted if the JPEG file is gray-scale or if
|
98
|
-
.B \-grayscale
|
99
|
-
is specified; otherwise PPM is emitted.
|
100
|
-
.TP
|
101
|
-
.B \-rle
|
102
|
-
Select RLE output format. (Requires URT library.)
|
103
|
-
.TP
|
104
|
-
.B \-targa
|
105
|
-
Select Targa output format. Gray-scale format is emitted if the JPEG file is
|
106
|
-
gray-scale or if
|
107
|
-
.B \-grayscale
|
108
|
-
is specified; otherwise, colormapped format is emitted if
|
109
|
-
.B \-colors
|
110
|
-
is specified; otherwise, 24-bit full-color format is emitted.
|
111
|
-
.PP
|
112
|
-
Switches for advanced users:
|
113
|
-
.TP
|
114
|
-
.B \-dct int
|
115
|
-
Use integer DCT method (default).
|
116
|
-
.TP
|
117
|
-
.B \-dct fast
|
118
|
-
Use fast integer DCT (less accurate).
|
119
|
-
.TP
|
120
|
-
.B \-dct float
|
121
|
-
Use floating-point DCT method.
|
122
|
-
The float method is very slightly more accurate than the int method, but is
|
123
|
-
much slower unless your machine has very fast floating-point hardware. Also
|
124
|
-
note that results of the floating-point method may vary slightly across
|
125
|
-
machines, while the integer methods should give the same results everywhere.
|
126
|
-
The fast integer method is much less accurate than the other two.
|
127
|
-
.TP
|
128
|
-
.B \-dither fs
|
129
|
-
Use Floyd-Steinberg dithering in color quantization.
|
130
|
-
.TP
|
131
|
-
.B \-dither ordered
|
132
|
-
Use ordered dithering in color quantization.
|
133
|
-
.TP
|
134
|
-
.B \-dither none
|
135
|
-
Do not use dithering in color quantization.
|
136
|
-
By default, Floyd-Steinberg dithering is applied when quantizing colors; this
|
137
|
-
is slow but usually produces the best results. Ordered dither is a compromise
|
138
|
-
between speed and quality; no dithering is fast but usually looks awful. Note
|
139
|
-
that these switches have no effect unless color quantization is being done.
|
140
|
-
Ordered dither is only available in
|
141
|
-
.B \-onepass
|
142
|
-
mode.
|
143
|
-
.TP
|
144
|
-
.BI \-map " file"
|
145
|
-
Quantize to the colors used in the specified image file. This is useful for
|
146
|
-
producing multiple files with identical color maps, or for forcing a
|
147
|
-
predefined set of colors to be used. The
|
148
|
-
.I file
|
149
|
-
must be a GIF or PPM file. This option overrides
|
150
|
-
.B \-colors
|
151
|
-
and
|
152
|
-
.BR \-onepass .
|
153
|
-
.TP
|
154
|
-
.B \-nosmooth
|
155
|
-
Don't use high-quality upsampling.
|
156
|
-
.TP
|
157
|
-
.B \-onepass
|
158
|
-
Use one-pass instead of two-pass color quantization. The one-pass method is
|
159
|
-
faster and needs less memory, but it produces a lower-quality image.
|
160
|
-
.B \-onepass
|
161
|
-
is ignored unless you also say
|
162
|
-
.B \-colors
|
163
|
-
.IR N .
|
164
|
-
Also, the one-pass method is always used for gray-scale output (the two-pass
|
165
|
-
method is no improvement then).
|
166
|
-
.TP
|
167
|
-
.BI \-maxmemory " N"
|
168
|
-
Set limit for amount of memory to use in processing large images. Value is
|
169
|
-
in thousands of bytes, or millions of bytes if "M" is attached to the
|
170
|
-
number. For example,
|
171
|
-
.B \-max 4m
|
172
|
-
selects 4000000 bytes. If more space is needed, temporary files will be used.
|
173
|
-
.TP
|
174
|
-
.BI \-outfile " name"
|
175
|
-
Send output image to the named file, not to standard output.
|
176
|
-
.TP
|
177
|
-
.B \-verbose
|
178
|
-
Enable debug printout. More
|
179
|
-
.BR \-v 's
|
180
|
-
give more output. Also, version information is printed at startup.
|
181
|
-
.TP
|
182
|
-
.B \-debug
|
183
|
-
Same as
|
184
|
-
.BR \-verbose .
|
185
|
-
.SH EXAMPLES
|
186
|
-
.LP
|
187
|
-
This example decompresses the JPEG file foo.jpg, quantizes it to
|
188
|
-
256 colors, and saves the output in 8-bit BMP format in foo.bmp:
|
189
|
-
.IP
|
190
|
-
.B djpeg \-colors 256 \-bmp
|
191
|
-
.I foo.jpg
|
192
|
-
.B >
|
193
|
-
.I foo.bmp
|
194
|
-
.SH HINTS
|
195
|
-
To get a quick preview of an image, use the
|
196
|
-
.B \-grayscale
|
197
|
-
and/or
|
198
|
-
.B \-scale
|
199
|
-
switches.
|
200
|
-
.B \-grayscale \-scale 1/8
|
201
|
-
is the fastest case.
|
202
|
-
.PP
|
203
|
-
Several options are available that trade off image quality to gain speed.
|
204
|
-
.B \-fast
|
205
|
-
turns on the recommended settings.
|
206
|
-
.PP
|
207
|
-
.B \-dct fast
|
208
|
-
and/or
|
209
|
-
.B \-nosmooth
|
210
|
-
gain speed at a small sacrifice in quality.
|
211
|
-
When producing a color-quantized image,
|
212
|
-
.B \-onepass \-dither ordered
|
213
|
-
is fast but much lower quality than the default behavior.
|
214
|
-
.B \-dither none
|
215
|
-
may give acceptable results in two-pass mode, but is seldom tolerable in
|
216
|
-
one-pass mode.
|
217
|
-
.PP
|
218
|
-
If you are fortunate enough to have very fast floating point hardware,
|
219
|
-
\fB\-dct float\fR may be even faster than \fB\-dct fast\fR. But on most
|
220
|
-
machines \fB\-dct float\fR is slower than \fB\-dct int\fR; in this case it is
|
221
|
-
not worth using, because its theoretical accuracy advantage is too small to be
|
222
|
-
significant in practice.
|
223
|
-
.SH ENVIRONMENT
|
224
|
-
.TP
|
225
|
-
.B JPEGMEM
|
226
|
-
If this environment variable is set, its value is the default memory limit.
|
227
|
-
The value is specified as described for the
|
228
|
-
.B \-maxmemory
|
229
|
-
switch.
|
230
|
-
.B JPEGMEM
|
231
|
-
overrides the default value specified when the program was compiled, and
|
232
|
-
itself is overridden by an explicit
|
233
|
-
.BR \-maxmemory .
|
234
|
-
.SH SEE ALSO
|
235
|
-
.BR cjpeg (1),
|
236
|
-
.BR jpegtran (1),
|
237
|
-
.BR rdjpgcom (1),
|
238
|
-
.BR wrjpgcom (1)
|
239
|
-
.br
|
240
|
-
.BR ppm (5),
|
241
|
-
.BR pgm (5)
|
242
|
-
.br
|
243
|
-
Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
|
244
|
-
Communications of the ACM, April 1991 (vol. 34, no. 4), pp. 30-44.
|
245
|
-
.SH AUTHOR
|
246
|
-
Independent JPEG Group
|
247
|
-
.SH BUGS
|
248
|
-
To avoid the Unisys LZW patent,
|
249
|
-
.B djpeg
|
250
|
-
produces uncompressed GIF files. These are larger than they should be, but
|
251
|
-
are readable by standard GIF decoders.
|
data/src/jpeg-7/djpeg.c
DELETED
@@ -1,617 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* djpeg.c
|
3
|
-
*
|
4
|
-
* Copyright (C) 1991-1997, Thomas G. Lane.
|
5
|
-
* Modified 2009 by Guido Vollbeding.
|
6
|
-
* This file is part of the Independent JPEG Group's software.
|
7
|
-
* For conditions of distribution and use, see the accompanying README file.
|
8
|
-
*
|
9
|
-
* This file contains a command-line user interface for the JPEG decompressor.
|
10
|
-
* It should work on any system with Unix- or MS-DOS-style command lines.
|
11
|
-
*
|
12
|
-
* Two different command line styles are permitted, depending on the
|
13
|
-
* compile-time switch TWO_FILE_COMMANDLINE:
|
14
|
-
* djpeg [options] inputfile outputfile
|
15
|
-
* djpeg [options] [inputfile]
|
16
|
-
* In the second style, output is always to standard output, which you'd
|
17
|
-
* normally redirect to a file or pipe to some other program. Input is
|
18
|
-
* either from a named file or from standard input (typically redirected).
|
19
|
-
* The second style is convenient on Unix but is unhelpful on systems that
|
20
|
-
* don't support pipes. Also, you MUST use the first style if your system
|
21
|
-
* doesn't do binary I/O to stdin/stdout.
|
22
|
-
* To simplify script writing, the "-outfile" switch is provided. The syntax
|
23
|
-
* djpeg [options] -outfile outputfile inputfile
|
24
|
-
* works regardless of which command line style is used.
|
25
|
-
*/
|
26
|
-
|
27
|
-
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
28
|
-
#include "jversion.h" /* for version message */
|
29
|
-
|
30
|
-
#include <ctype.h> /* to declare isprint() */
|
31
|
-
|
32
|
-
#ifdef USE_CCOMMAND /* command-line reader for Macintosh */
|
33
|
-
#ifdef __MWERKS__
|
34
|
-
#include <SIOUX.h> /* Metrowerks needs this */
|
35
|
-
#include <console.h> /* ... and this */
|
36
|
-
#endif
|
37
|
-
#ifdef THINK_C
|
38
|
-
#include <console.h> /* Think declares it here */
|
39
|
-
#endif
|
40
|
-
#endif
|
41
|
-
|
42
|
-
|
43
|
-
/* Create the add-on message string table. */
|
44
|
-
|
45
|
-
#define JMESSAGE(code,string) string ,
|
46
|
-
|
47
|
-
static const char * const cdjpeg_message_table[] = {
|
48
|
-
#include "cderror.h"
|
49
|
-
NULL
|
50
|
-
};
|
51
|
-
|
52
|
-
|
53
|
-
/*
|
54
|
-
* This list defines the known output image formats
|
55
|
-
* (not all of which need be supported by a given version).
|
56
|
-
* You can change the default output format by defining DEFAULT_FMT;
|
57
|
-
* indeed, you had better do so if you undefine PPM_SUPPORTED.
|
58
|
-
*/
|
59
|
-
|
60
|
-
typedef enum {
|
61
|
-
FMT_BMP, /* BMP format (Windows flavor) */
|
62
|
-
FMT_GIF, /* GIF format */
|
63
|
-
FMT_OS2, /* BMP format (OS/2 flavor) */
|
64
|
-
FMT_PPM, /* PPM/PGM (PBMPLUS formats) */
|
65
|
-
FMT_RLE, /* RLE format */
|
66
|
-
FMT_TARGA, /* Targa format */
|
67
|
-
FMT_TIFF /* TIFF format */
|
68
|
-
} IMAGE_FORMATS;
|
69
|
-
|
70
|
-
#ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */
|
71
|
-
#define DEFAULT_FMT FMT_PPM
|
72
|
-
#endif
|
73
|
-
|
74
|
-
static IMAGE_FORMATS requested_fmt;
|
75
|
-
|
76
|
-
|
77
|
-
/*
|
78
|
-
* Argument-parsing code.
|
79
|
-
* The switch parser is designed to be useful with DOS-style command line
|
80
|
-
* syntax, ie, intermixed switches and file names, where only the switches
|
81
|
-
* to the left of a given file name affect processing of that file.
|
82
|
-
* The main program in this file doesn't actually use this capability...
|
83
|
-
*/
|
84
|
-
|
85
|
-
|
86
|
-
static const char * progname; /* program name for error messages */
|
87
|
-
static char * outfilename; /* for -outfile switch */
|
88
|
-
|
89
|
-
|
90
|
-
LOCAL(void)
|
91
|
-
usage (void)
|
92
|
-
/* complain about bad command line */
|
93
|
-
{
|
94
|
-
fprintf(stderr, "usage: %s [switches] ", progname);
|
95
|
-
#ifdef TWO_FILE_COMMANDLINE
|
96
|
-
fprintf(stderr, "inputfile outputfile\n");
|
97
|
-
#else
|
98
|
-
fprintf(stderr, "[inputfile]\n");
|
99
|
-
#endif
|
100
|
-
|
101
|
-
fprintf(stderr, "Switches (names may be abbreviated):\n");
|
102
|
-
fprintf(stderr, " -colors N Reduce image to no more than N colors\n");
|
103
|
-
fprintf(stderr, " -fast Fast, low-quality processing\n");
|
104
|
-
fprintf(stderr, " -grayscale Force grayscale output\n");
|
105
|
-
#ifdef IDCT_SCALING_SUPPORTED
|
106
|
-
fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n");
|
107
|
-
#endif
|
108
|
-
#ifdef BMP_SUPPORTED
|
109
|
-
fprintf(stderr, " -bmp Select BMP output format (Windows style)%s\n",
|
110
|
-
(DEFAULT_FMT == FMT_BMP ? " (default)" : ""));
|
111
|
-
#endif
|
112
|
-
#ifdef GIF_SUPPORTED
|
113
|
-
fprintf(stderr, " -gif Select GIF output format%s\n",
|
114
|
-
(DEFAULT_FMT == FMT_GIF ? " (default)" : ""));
|
115
|
-
#endif
|
116
|
-
#ifdef BMP_SUPPORTED
|
117
|
-
fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n",
|
118
|
-
(DEFAULT_FMT == FMT_OS2 ? " (default)" : ""));
|
119
|
-
#endif
|
120
|
-
#ifdef PPM_SUPPORTED
|
121
|
-
fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n",
|
122
|
-
(DEFAULT_FMT == FMT_PPM ? " (default)" : ""));
|
123
|
-
#endif
|
124
|
-
#ifdef RLE_SUPPORTED
|
125
|
-
fprintf(stderr, " -rle Select Utah RLE output format%s\n",
|
126
|
-
(DEFAULT_FMT == FMT_RLE ? " (default)" : ""));
|
127
|
-
#endif
|
128
|
-
#ifdef TARGA_SUPPORTED
|
129
|
-
fprintf(stderr, " -targa Select Targa output format%s\n",
|
130
|
-
(DEFAULT_FMT == FMT_TARGA ? " (default)" : ""));
|
131
|
-
#endif
|
132
|
-
fprintf(stderr, "Switches for advanced users:\n");
|
133
|
-
#ifdef DCT_ISLOW_SUPPORTED
|
134
|
-
fprintf(stderr, " -dct int Use integer DCT method%s\n",
|
135
|
-
(JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : ""));
|
136
|
-
#endif
|
137
|
-
#ifdef DCT_IFAST_SUPPORTED
|
138
|
-
fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n",
|
139
|
-
(JDCT_DEFAULT == JDCT_IFAST ? " (default)" : ""));
|
140
|
-
#endif
|
141
|
-
#ifdef DCT_FLOAT_SUPPORTED
|
142
|
-
fprintf(stderr, " -dct float Use floating-point DCT method%s\n",
|
143
|
-
(JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
|
144
|
-
#endif
|
145
|
-
fprintf(stderr, " -dither fs Use F-S dithering (default)\n");
|
146
|
-
fprintf(stderr, " -dither none Don't use dithering in quantization\n");
|
147
|
-
fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n");
|
148
|
-
#ifdef QUANT_2PASS_SUPPORTED
|
149
|
-
fprintf(stderr, " -map FILE Map to colors used in named image file\n");
|
150
|
-
#endif
|
151
|
-
fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n");
|
152
|
-
#ifdef QUANT_1PASS_SUPPORTED
|
153
|
-
fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n");
|
154
|
-
#endif
|
155
|
-
fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
|
156
|
-
fprintf(stderr, " -outfile name Specify name for output file\n");
|
157
|
-
fprintf(stderr, " -verbose or -debug Emit debug output\n");
|
158
|
-
exit(EXIT_FAILURE);
|
159
|
-
}
|
160
|
-
|
161
|
-
|
162
|
-
LOCAL(int)
|
163
|
-
parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
|
164
|
-
int last_file_arg_seen, boolean for_real)
|
165
|
-
/* Parse optional switches.
|
166
|
-
* Returns argv[] index of first file-name argument (== argc if none).
|
167
|
-
* Any file names with indexes <= last_file_arg_seen are ignored;
|
168
|
-
* they have presumably been processed in a previous iteration.
|
169
|
-
* (Pass 0 for last_file_arg_seen on the first or only iteration.)
|
170
|
-
* for_real is FALSE on the first (dummy) pass; we may skip any expensive
|
171
|
-
* processing.
|
172
|
-
*/
|
173
|
-
{
|
174
|
-
int argn;
|
175
|
-
char * arg;
|
176
|
-
|
177
|
-
/* Set up default JPEG parameters. */
|
178
|
-
requested_fmt = DEFAULT_FMT; /* set default output file format */
|
179
|
-
outfilename = NULL;
|
180
|
-
cinfo->err->trace_level = 0;
|
181
|
-
|
182
|
-
/* Scan command line options, adjust parameters */
|
183
|
-
|
184
|
-
for (argn = 1; argn < argc; argn++) {
|
185
|
-
arg = argv[argn];
|
186
|
-
if (*arg != '-') {
|
187
|
-
/* Not a switch, must be a file name argument */
|
188
|
-
if (argn <= last_file_arg_seen) {
|
189
|
-
outfilename = NULL; /* -outfile applies to just one input file */
|
190
|
-
continue; /* ignore this name if previously processed */
|
191
|
-
}
|
192
|
-
break; /* else done parsing switches */
|
193
|
-
}
|
194
|
-
arg++; /* advance past switch marker character */
|
195
|
-
|
196
|
-
if (keymatch(arg, "bmp", 1)) {
|
197
|
-
/* BMP output format. */
|
198
|
-
requested_fmt = FMT_BMP;
|
199
|
-
|
200
|
-
} else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) ||
|
201
|
-
keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) {
|
202
|
-
/* Do color quantization. */
|
203
|
-
int val;
|
204
|
-
|
205
|
-
if (++argn >= argc) /* advance to next argument */
|
206
|
-
usage();
|
207
|
-
if (sscanf(argv[argn], "%d", &val) != 1)
|
208
|
-
usage();
|
209
|
-
cinfo->desired_number_of_colors = val;
|
210
|
-
cinfo->quantize_colors = TRUE;
|
211
|
-
|
212
|
-
} else if (keymatch(arg, "dct", 2)) {
|
213
|
-
/* Select IDCT algorithm. */
|
214
|
-
if (++argn >= argc) /* advance to next argument */
|
215
|
-
usage();
|
216
|
-
if (keymatch(argv[argn], "int", 1)) {
|
217
|
-
cinfo->dct_method = JDCT_ISLOW;
|
218
|
-
} else if (keymatch(argv[argn], "fast", 2)) {
|
219
|
-
cinfo->dct_method = JDCT_IFAST;
|
220
|
-
} else if (keymatch(argv[argn], "float", 2)) {
|
221
|
-
cinfo->dct_method = JDCT_FLOAT;
|
222
|
-
} else
|
223
|
-
usage();
|
224
|
-
|
225
|
-
} else if (keymatch(arg, "dither", 2)) {
|
226
|
-
/* Select dithering algorithm. */
|
227
|
-
if (++argn >= argc) /* advance to next argument */
|
228
|
-
usage();
|
229
|
-
if (keymatch(argv[argn], "fs", 2)) {
|
230
|
-
cinfo->dither_mode = JDITHER_FS;
|
231
|
-
} else if (keymatch(argv[argn], "none", 2)) {
|
232
|
-
cinfo->dither_mode = JDITHER_NONE;
|
233
|
-
} else if (keymatch(argv[argn], "ordered", 2)) {
|
234
|
-
cinfo->dither_mode = JDITHER_ORDERED;
|
235
|
-
} else
|
236
|
-
usage();
|
237
|
-
|
238
|
-
} else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
|
239
|
-
/* Enable debug printouts. */
|
240
|
-
/* On first -d, print version identification */
|
241
|
-
static boolean printed_version = FALSE;
|
242
|
-
|
243
|
-
if (! printed_version) {
|
244
|
-
fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n",
|
245
|
-
JVERSION, JCOPYRIGHT);
|
246
|
-
printed_version = TRUE;
|
247
|
-
}
|
248
|
-
cinfo->err->trace_level++;
|
249
|
-
|
250
|
-
} else if (keymatch(arg, "fast", 1)) {
|
251
|
-
/* Select recommended processing options for quick-and-dirty output. */
|
252
|
-
cinfo->two_pass_quantize = FALSE;
|
253
|
-
cinfo->dither_mode = JDITHER_ORDERED;
|
254
|
-
if (! cinfo->quantize_colors) /* don't override an earlier -colors */
|
255
|
-
cinfo->desired_number_of_colors = 216;
|
256
|
-
cinfo->dct_method = JDCT_FASTEST;
|
257
|
-
cinfo->do_fancy_upsampling = FALSE;
|
258
|
-
|
259
|
-
} else if (keymatch(arg, "gif", 1)) {
|
260
|
-
/* GIF output format. */
|
261
|
-
requested_fmt = FMT_GIF;
|
262
|
-
|
263
|
-
} else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
|
264
|
-
/* Force monochrome output. */
|
265
|
-
cinfo->out_color_space = JCS_GRAYSCALE;
|
266
|
-
|
267
|
-
} else if (keymatch(arg, "map", 3)) {
|
268
|
-
/* Quantize to a color map taken from an input file. */
|
269
|
-
if (++argn >= argc) /* advance to next argument */
|
270
|
-
usage();
|
271
|
-
if (for_real) { /* too expensive to do twice! */
|
272
|
-
#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */
|
273
|
-
FILE * mapfile;
|
274
|
-
|
275
|
-
if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) {
|
276
|
-
fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]);
|
277
|
-
exit(EXIT_FAILURE);
|
278
|
-
}
|
279
|
-
read_color_map(cinfo, mapfile);
|
280
|
-
fclose(mapfile);
|
281
|
-
cinfo->quantize_colors = TRUE;
|
282
|
-
#else
|
283
|
-
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
284
|
-
#endif
|
285
|
-
}
|
286
|
-
|
287
|
-
} else if (keymatch(arg, "maxmemory", 3)) {
|
288
|
-
/* Maximum memory in Kb (or Mb with 'm'). */
|
289
|
-
long lval;
|
290
|
-
char ch = 'x';
|
291
|
-
|
292
|
-
if (++argn >= argc) /* advance to next argument */
|
293
|
-
usage();
|
294
|
-
if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
|
295
|
-
usage();
|
296
|
-
if (ch == 'm' || ch == 'M')
|
297
|
-
lval *= 1000L;
|
298
|
-
cinfo->mem->max_memory_to_use = lval * 1000L;
|
299
|
-
|
300
|
-
} else if (keymatch(arg, "nosmooth", 3)) {
|
301
|
-
/* Suppress fancy upsampling */
|
302
|
-
cinfo->do_fancy_upsampling = FALSE;
|
303
|
-
|
304
|
-
} else if (keymatch(arg, "onepass", 3)) {
|
305
|
-
/* Use fast one-pass quantization. */
|
306
|
-
cinfo->two_pass_quantize = FALSE;
|
307
|
-
|
308
|
-
} else if (keymatch(arg, "os2", 3)) {
|
309
|
-
/* BMP output format (OS/2 flavor). */
|
310
|
-
requested_fmt = FMT_OS2;
|
311
|
-
|
312
|
-
} else if (keymatch(arg, "outfile", 4)) {
|
313
|
-
/* Set output file name. */
|
314
|
-
if (++argn >= argc) /* advance to next argument */
|
315
|
-
usage();
|
316
|
-
outfilename = argv[argn]; /* save it away for later use */
|
317
|
-
|
318
|
-
} else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) {
|
319
|
-
/* PPM/PGM output format. */
|
320
|
-
requested_fmt = FMT_PPM;
|
321
|
-
|
322
|
-
} else if (keymatch(arg, "rle", 1)) {
|
323
|
-
/* RLE output format. */
|
324
|
-
requested_fmt = FMT_RLE;
|
325
|
-
|
326
|
-
} else if (keymatch(arg, "scale", 1)) {
|
327
|
-
/* Scale the output image by a fraction M/N. */
|
328
|
-
if (++argn >= argc) /* advance to next argument */
|
329
|
-
usage();
|
330
|
-
if (sscanf(argv[argn], "%d/%d",
|
331
|
-
&cinfo->scale_num, &cinfo->scale_denom) < 1)
|
332
|
-
usage();
|
333
|
-
|
334
|
-
} else if (keymatch(arg, "targa", 1)) {
|
335
|
-
/* Targa output format. */
|
336
|
-
requested_fmt = FMT_TARGA;
|
337
|
-
|
338
|
-
} else {
|
339
|
-
usage(); /* bogus switch */
|
340
|
-
}
|
341
|
-
}
|
342
|
-
|
343
|
-
return argn; /* return index of next arg (file name) */
|
344
|
-
}
|
345
|
-
|
346
|
-
|
347
|
-
/*
|
348
|
-
* Marker processor for COM and interesting APPn markers.
|
349
|
-
* This replaces the library's built-in processor, which just skips the marker.
|
350
|
-
* We want to print out the marker as text, to the extent possible.
|
351
|
-
* Note this code relies on a non-suspending data source.
|
352
|
-
*/
|
353
|
-
|
354
|
-
LOCAL(unsigned int)
|
355
|
-
jpeg_getc (j_decompress_ptr cinfo)
|
356
|
-
/* Read next byte */
|
357
|
-
{
|
358
|
-
struct jpeg_source_mgr * datasrc = cinfo->src;
|
359
|
-
|
360
|
-
if (datasrc->bytes_in_buffer == 0) {
|
361
|
-
if (! (*datasrc->fill_input_buffer) (cinfo))
|
362
|
-
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
363
|
-
}
|
364
|
-
datasrc->bytes_in_buffer--;
|
365
|
-
return GETJOCTET(*datasrc->next_input_byte++);
|
366
|
-
}
|
367
|
-
|
368
|
-
|
369
|
-
METHODDEF(boolean)
|
370
|
-
print_text_marker (j_decompress_ptr cinfo)
|
371
|
-
{
|
372
|
-
boolean traceit = (cinfo->err->trace_level >= 1);
|
373
|
-
INT32 length;
|
374
|
-
unsigned int ch;
|
375
|
-
unsigned int lastch = 0;
|
376
|
-
|
377
|
-
length = jpeg_getc(cinfo) << 8;
|
378
|
-
length += jpeg_getc(cinfo);
|
379
|
-
length -= 2; /* discount the length word itself */
|
380
|
-
|
381
|
-
if (traceit) {
|
382
|
-
if (cinfo->unread_marker == JPEG_COM)
|
383
|
-
fprintf(stderr, "Comment, length %ld:\n", (long) length);
|
384
|
-
else /* assume it is an APPn otherwise */
|
385
|
-
fprintf(stderr, "APP%d, length %ld:\n",
|
386
|
-
cinfo->unread_marker - JPEG_APP0, (long) length);
|
387
|
-
}
|
388
|
-
|
389
|
-
while (--length >= 0) {
|
390
|
-
ch = jpeg_getc(cinfo);
|
391
|
-
if (traceit) {
|
392
|
-
/* Emit the character in a readable form.
|
393
|
-
* Nonprintables are converted to \nnn form,
|
394
|
-
* while \ is converted to \\.
|
395
|
-
* Newlines in CR, CR/LF, or LF form will be printed as one newline.
|
396
|
-
*/
|
397
|
-
if (ch == '\r') {
|
398
|
-
fprintf(stderr, "\n");
|
399
|
-
} else if (ch == '\n') {
|
400
|
-
if (lastch != '\r')
|
401
|
-
fprintf(stderr, "\n");
|
402
|
-
} else if (ch == '\\') {
|
403
|
-
fprintf(stderr, "\\\\");
|
404
|
-
} else if (isprint(ch)) {
|
405
|
-
putc(ch, stderr);
|
406
|
-
} else {
|
407
|
-
fprintf(stderr, "\\%03o", ch);
|
408
|
-
}
|
409
|
-
lastch = ch;
|
410
|
-
}
|
411
|
-
}
|
412
|
-
|
413
|
-
if (traceit)
|
414
|
-
fprintf(stderr, "\n");
|
415
|
-
|
416
|
-
return TRUE;
|
417
|
-
}
|
418
|
-
|
419
|
-
|
420
|
-
/*
|
421
|
-
* The main program.
|
422
|
-
*/
|
423
|
-
|
424
|
-
int
|
425
|
-
main (int argc, char **argv)
|
426
|
-
{
|
427
|
-
struct jpeg_decompress_struct cinfo;
|
428
|
-
struct jpeg_error_mgr jerr;
|
429
|
-
#ifdef PROGRESS_REPORT
|
430
|
-
struct cdjpeg_progress_mgr progress;
|
431
|
-
#endif
|
432
|
-
int file_index;
|
433
|
-
djpeg_dest_ptr dest_mgr = NULL;
|
434
|
-
FILE * input_file;
|
435
|
-
FILE * output_file;
|
436
|
-
JDIMENSION num_scanlines;
|
437
|
-
|
438
|
-
/* On Mac, fetch a command line. */
|
439
|
-
#ifdef USE_CCOMMAND
|
440
|
-
argc = ccommand(&argv);
|
441
|
-
#endif
|
442
|
-
|
443
|
-
progname = argv[0];
|
444
|
-
if (progname == NULL || progname[0] == 0)
|
445
|
-
progname = "djpeg"; /* in case C library doesn't provide it */
|
446
|
-
|
447
|
-
/* Initialize the JPEG decompression object with default error handling. */
|
448
|
-
cinfo.err = jpeg_std_error(&jerr);
|
449
|
-
jpeg_create_decompress(&cinfo);
|
450
|
-
/* Add some application-specific error messages (from cderror.h) */
|
451
|
-
jerr.addon_message_table = cdjpeg_message_table;
|
452
|
-
jerr.first_addon_message = JMSG_FIRSTADDONCODE;
|
453
|
-
jerr.last_addon_message = JMSG_LASTADDONCODE;
|
454
|
-
|
455
|
-
/* Insert custom marker processor for COM and APP12.
|
456
|
-
* APP12 is used by some digital camera makers for textual info,
|
457
|
-
* so we provide the ability to display it as text.
|
458
|
-
* If you like, additional APPn marker types can be selected for display,
|
459
|
-
* but don't try to override APP0 or APP14 this way (see libjpeg.doc).
|
460
|
-
*/
|
461
|
-
jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker);
|
462
|
-
jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker);
|
463
|
-
|
464
|
-
/* Now safe to enable signal catcher. */
|
465
|
-
#ifdef NEED_SIGNAL_CATCHER
|
466
|
-
enable_signal_catcher((j_common_ptr) &cinfo);
|
467
|
-
#endif
|
468
|
-
|
469
|
-
/* Scan command line to find file names. */
|
470
|
-
/* It is convenient to use just one switch-parsing routine, but the switch
|
471
|
-
* values read here are ignored; we will rescan the switches after opening
|
472
|
-
* the input file.
|
473
|
-
* (Exception: tracing level set here controls verbosity for COM markers
|
474
|
-
* found during jpeg_read_header...)
|
475
|
-
*/
|
476
|
-
|
477
|
-
file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);
|
478
|
-
|
479
|
-
#ifdef TWO_FILE_COMMANDLINE
|
480
|
-
/* Must have either -outfile switch or explicit output file name */
|
481
|
-
if (outfilename == NULL) {
|
482
|
-
if (file_index != argc-2) {
|
483
|
-
fprintf(stderr, "%s: must name one input and one output file\n",
|
484
|
-
progname);
|
485
|
-
usage();
|
486
|
-
}
|
487
|
-
outfilename = argv[file_index+1];
|
488
|
-
} else {
|
489
|
-
if (file_index != argc-1) {
|
490
|
-
fprintf(stderr, "%s: must name one input and one output file\n",
|
491
|
-
progname);
|
492
|
-
usage();
|
493
|
-
}
|
494
|
-
}
|
495
|
-
#else
|
496
|
-
/* Unix style: expect zero or one file name */
|
497
|
-
if (file_index < argc-1) {
|
498
|
-
fprintf(stderr, "%s: only one input file\n", progname);
|
499
|
-
usage();
|
500
|
-
}
|
501
|
-
#endif /* TWO_FILE_COMMANDLINE */
|
502
|
-
|
503
|
-
/* Open the input file. */
|
504
|
-
if (file_index < argc) {
|
505
|
-
if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {
|
506
|
-
fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]);
|
507
|
-
exit(EXIT_FAILURE);
|
508
|
-
}
|
509
|
-
} else {
|
510
|
-
/* default input file is stdin */
|
511
|
-
input_file = read_stdin();
|
512
|
-
}
|
513
|
-
|
514
|
-
/* Open the output file. */
|
515
|
-
if (outfilename != NULL) {
|
516
|
-
if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {
|
517
|
-
fprintf(stderr, "%s: can't open %s\n", progname, outfilename);
|
518
|
-
exit(EXIT_FAILURE);
|
519
|
-
}
|
520
|
-
} else {
|
521
|
-
/* default output file is stdout */
|
522
|
-
output_file = write_stdout();
|
523
|
-
}
|
524
|
-
|
525
|
-
#ifdef PROGRESS_REPORT
|
526
|
-
start_progress_monitor((j_common_ptr) &cinfo, &progress);
|
527
|
-
#endif
|
528
|
-
|
529
|
-
/* Specify data source for decompression */
|
530
|
-
jpeg_stdio_src(&cinfo, input_file);
|
531
|
-
|
532
|
-
/* Read file header, set default decompression parameters */
|
533
|
-
(void) jpeg_read_header(&cinfo, TRUE);
|
534
|
-
|
535
|
-
/* Adjust default decompression parameters by re-parsing the options */
|
536
|
-
file_index = parse_switches(&cinfo, argc, argv, 0, TRUE);
|
537
|
-
|
538
|
-
/* Initialize the output module now to let it override any crucial
|
539
|
-
* option settings (for instance, GIF wants to force color quantization).
|
540
|
-
*/
|
541
|
-
switch (requested_fmt) {
|
542
|
-
#ifdef BMP_SUPPORTED
|
543
|
-
case FMT_BMP:
|
544
|
-
dest_mgr = jinit_write_bmp(&cinfo, FALSE);
|
545
|
-
break;
|
546
|
-
case FMT_OS2:
|
547
|
-
dest_mgr = jinit_write_bmp(&cinfo, TRUE);
|
548
|
-
break;
|
549
|
-
#endif
|
550
|
-
#ifdef GIF_SUPPORTED
|
551
|
-
case FMT_GIF:
|
552
|
-
dest_mgr = jinit_write_gif(&cinfo);
|
553
|
-
break;
|
554
|
-
#endif
|
555
|
-
#ifdef PPM_SUPPORTED
|
556
|
-
case FMT_PPM:
|
557
|
-
dest_mgr = jinit_write_ppm(&cinfo);
|
558
|
-
break;
|
559
|
-
#endif
|
560
|
-
#ifdef RLE_SUPPORTED
|
561
|
-
case FMT_RLE:
|
562
|
-
dest_mgr = jinit_write_rle(&cinfo);
|
563
|
-
break;
|
564
|
-
#endif
|
565
|
-
#ifdef TARGA_SUPPORTED
|
566
|
-
case FMT_TARGA:
|
567
|
-
dest_mgr = jinit_write_targa(&cinfo);
|
568
|
-
break;
|
569
|
-
#endif
|
570
|
-
default:
|
571
|
-
ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);
|
572
|
-
break;
|
573
|
-
}
|
574
|
-
dest_mgr->output_file = output_file;
|
575
|
-
|
576
|
-
/* Start decompressor */
|
577
|
-
(void) jpeg_start_decompress(&cinfo);
|
578
|
-
|
579
|
-
/* Write output file header */
|
580
|
-
(*dest_mgr->start_output) (&cinfo, dest_mgr);
|
581
|
-
|
582
|
-
/* Process data */
|
583
|
-
while (cinfo.output_scanline < cinfo.output_height) {
|
584
|
-
num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
|
585
|
-
dest_mgr->buffer_height);
|
586
|
-
(*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
|
587
|
-
}
|
588
|
-
|
589
|
-
#ifdef PROGRESS_REPORT
|
590
|
-
/* Hack: count final pass as done in case finish_output does an extra pass.
|
591
|
-
* The library won't have updated completed_passes.
|
592
|
-
*/
|
593
|
-
progress.pub.completed_passes = progress.pub.total_passes;
|
594
|
-
#endif
|
595
|
-
|
596
|
-
/* Finish decompression and release memory.
|
597
|
-
* I must do it in this order because output module has allocated memory
|
598
|
-
* of lifespan JPOOL_IMAGE; it needs to finish before releasing memory.
|
599
|
-
*/
|
600
|
-
(*dest_mgr->finish_output) (&cinfo, dest_mgr);
|
601
|
-
(void) jpeg_finish_decompress(&cinfo);
|
602
|
-
jpeg_destroy_decompress(&cinfo);
|
603
|
-
|
604
|
-
/* Close files, if we opened them */
|
605
|
-
if (input_file != stdin)
|
606
|
-
fclose(input_file);
|
607
|
-
if (output_file != stdout)
|
608
|
-
fclose(output_file);
|
609
|
-
|
610
|
-
#ifdef PROGRESS_REPORT
|
611
|
-
end_progress_monitor((j_common_ptr) &cinfo);
|
612
|
-
#endif
|
613
|
-
|
614
|
-
/* All done. */
|
615
|
-
exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);
|
616
|
-
return 0; /* suppress no-return-value warnings */
|
617
|
-
}
|