]> git.saurik.com Git - wxWidgets.git/blame - src/tiff/man/tiffcrop.1
Second part of #15224 fix: AddRows, AddColumns (dghart)
[wxWidgets.git] / src / tiff / man / tiffcrop.1
CommitLineData
80ed523f
VZ
1.\" tiffcrop -- a port of tiffcp.c extended to include extended processing of images
2.\"
3.\" Original code:
4.\"
5.\" Copyright (c) 1988-1997 Sam Leffler
6.\" Copyright (c) 1991-1997 Silicon Graphics, Inc.
7.\"
8.\" Permission to use, copy, modify, distribute, and sell this software and
9.\" its documentation for any purpose is hereby granted without fee, provided
10.\" that (i) the above copyright notices and this permission notice appear in
11.\" all copies of the software and related documentation, and (ii) the names of
12.\" Sam Leffler and Silicon Graphics may not be used in any advertising or
13.\" publicity relating to the software without the specific, prior written
14.\" permission of Sam Leffler and Silicon Graphics.
15.\"
16.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
17.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19.\"
20.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
21.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
22.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
23.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
24.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
25.\" OF THIS SOFTWARE.
26.\"
27.\" Additional code Copyright (c) 2006-2009 Richard Nolde
28.\" Lasted Updated 9/2009
29.\" .if n .po 0
30.TH "TIFFCROP" "1" "December, 2008" "libtiff" ""
31.SH "NAME"
32tiffcrop \- select, copy, crop, convert, extract, and/or process one or more
33.SM TIFF
34files.
35.SH "SYNOPSIS"
36.B tiffcrop
37[
38.I options
39]
40.I "src1.tif ... srcN.tif dst.tif"
41.SH "DESCRIPTION"
42.I Tiffcrop
43processes one or more files created according
44to the Tag Image File Format, Revision 6.0, specification
45into one or more
46.SM TIFF
47file(s).
48.I Tiffcrop
49is most often used to extract portions of an image for processing
50with bar code recognizer or OCR software when that software cannot
51restrict the region of interest to a specific portion of the image
52or to improve efficiency when the regions of interest must be rotated.
53It can also be used to subdivide all or part of a processed image into
54smaller sections and export individual images or sections of images
55as separate files or separate images within one or more files derived
56from the original input image or images.
57.PP
58The available functions can be grouped broadly into three classes:
59.IP
60Those that select individual images or sections of images from the input files.
61The options \-N for sequences or lists of individual images in the input files,
62\-Z for zones, \-z for regions, \-X and \-Y for fixed sized selections,
63\-m for margins, \-U for units, and \-E for edge reference provide a variety of
64ways to specify portions of the input image.
65.IP
66Those that allow the individual images or selections to be exported to one or
67more output files in different groupings and control the organization of the
68data in the output images. The options \-P for page size grouping, \-S for
69subdivision into columns and rows and \-e for export mode options that produce
70one or more files from each input image. The options \-r, \-s, \-t, \-w control
71strip and tile format and sizes while \-B \-L \-c \-f modify the endian addressing
72scheme, the compression options, and the bit fill sequence of images as they
73are written.
74.IP
75Those that perform some action on each image that is selected from the input file.
76The options include \-R for rotate, \-I for inversion of the photometric
77interpretation and/or data values, and \-F to flip (mirror) the image horizontally
78or vertically.
79.PP
80
81Functions are applied to the input image(s) in the following order:
82cropping, fixed area extraction, zone and region extraction,
83inversion, mirroring, rotation.
84.PP
85Functions are applied to the output image(s) in the following order:
86export mode options for grouping zones, regions, or images into
87one or more files,
88.I or
89row and column divisions with output margins,
90.I or
91page size divisions with page orientation options.
92.PP
93Finally, strip, tile, byte order, output resolution, and compression options are
94applied to all output images.
95.PP
96The output file(s) may be organized and compressed using a different
97algorithm from the input files.
98By default,
99.I tiffcrop
100will copy all the understood tags in a
101.SM TIFF
102directory of an input file to the associated directory in the output file.
103Options can be used to force the resultant image to be written as strips
104or tiles of data, respectively.
105.PP
106.I Tiffcrop
107can be used to reorganize the storage characteristics of data
108in a file, and to reorganize, extract, rotate, and otherwise
109process the image data as specified at the same time whereas
110tiffcp does not alter the image data within the file.
111.PP
112Using the options for selecting individual input images and the
113options for exporting images and/or segments defined as zones or
114regions of each input image,
115.I tiffcrop
116can perform the functions of tiffcp and tiffsplit in a single pass
117while applying multiple operations to individual selections or images.
118.PP
119.SH "OPTIONS"
120.TP
121.B \-h
122Display the syntax summary for tiffcrop.
123.TP
124.B \-v
125Report the current version and last modification date for tiffcrop.
126.TP
127.B \-N odd|even|#,#\-#,#|last
128Specify one or more series or range(s) of images within each file to process.
129The words
130.B odd
131or
132.B even
133may be used to specify all odd or even numbered images counting from one.
134Note that internally, TIFF images are numbered from zero rather than one
135but since this convention is not obvious to most users, tiffcrop used 1
136to specifiy the first image in a multipage file. The word
137.B last
138may be used in place of a number in the sequence to indicate the
139final image in the file without knowing how many images there are.
140Ranges of images may be specified with a dash and multiple sets
141can be indicated by joining them in a comma\-separated list. eg. use
142.B \-N 1,5\-7,last
143to process the 1st, 5th through 7th, and final image in the file.
144.TP
145.B \-E top|bottom|left|right
146Specify the top, bottom, left, or right edge as the reference from
147which to calcuate the width and length of crop regions or sequence
148of postions for zones. When used with the \-e option for exporting
149zones or regions, the reference edge determines how composite images
150are arranged. Using \-E left or right causes successive zones or
151regions to be merged horizontally whereas using \-E top or bottom
152causes successive zones or regions to be arranged vertically. This
153option has no effect on export layout when multiple zones or regions
154are not being exported to composite images. Edges may be abbreviated
155to the first letter.
156.TP
157.B \-e combined|divided|image|multiple|separate
158Specify the export mode for images and selections from input images.
159The final filename on the command line is considered to be the
160destination file or filename stem for automatically generated
161sequences of files. Modes may be abbreviated to the first letter.
162.IP
163combined All images and selections are written to a single file with
164multiple selections from one image combined into a single image (default)
165.IP
166divided All images and selections are written to a single file
167with each selection from one image written to a new image
168.IP
169image Each input image is written to a new file (numeric filename sequence)
170with multiple selections from the image combined into one image
171.IP
172multiple Each input image is written to a new file (numeric filename sequence)
173with each selection from the image written to a new image
174.IP
175separate Individual selections from each image are written to separate files
176.TP
177.B \-U in|cm|px
178Specify the type of units to apply to dimensions for margins and
179crop regions for input and output images. Inches or centimeters
180are converted to pixels using the resolution unit specified in the
181TIFF file (which defaults to inches if not specified in the IFD).
182.TP
183.B \-m #,#,#,#
184Specify margins to be removed from the input image. The order must
185be top, left, bottom, right with only commas separating the elements
186of the list. Margins are scaled according to the current units and
187removed before any other extractions are computed..
188.TP
189.B \-X #
190Set the horizontal (X\-axis) dimension of a region to extract relative to
191the specified origin reference. If the origin is the top or bottom
192edge, the X axis value will be assumed to start at the left edge.
193.TP
194.B \-Y #
195Set the vertical (Y\-axis) dimension of a region to extract relative to
196the specified origin reference. If the origin is the left or right
197edge, the Y axis value will be assumed to start at the top.
198.TP
199.B \-Z #:#,#:#
200Specify zones of the image designated as position X of Y equal sized portions
201measured from the reference edge, eg 1:3 would be first third of the
202image starting from the reference edge minus any margins specified
203for the confining edges. Multiple zones can be specified as a comma
204separated list but they must reference the same edge. To extract the
205top quarter and the bottom third of an image you would use
206.B \-Z 1:4,3:3.
207.TP
208.B \-z x1,y1,x2,y2: ... :xN,yN,xN+1,yN+1
209Specify a series of coordinates to define regions for processing and exporting.
210The coordinates represent the top left and lower right corners of each region
211in the current units, eg inch, cm, or pixels. Pixels are counted from one to
212width or height and inches or cm are calculated from image resolution data.
213
214Each colon delimited series of four values represents the horizontal and vertical
215offsets from the top and left edges of the image, regardless of the edge specified
216with the \-E option. The first and third values represent the horizontal offsets of
217the corner points from the left edge while the second and fourth values represent
218the vertical offsets from the top edge.
219.TP
220.B \-F horiz|vert
221Flip, ie mirror, the image or extracted region horizontally or vertically.
222.TP
223.B \-R 90|180|270
224Rotate the image or extracted region 90, 180, or 270 degrees clockwise.
225.TP
226.B \\-I [black|white|data|both]
227Invert color space, eg dark to light for bilevel and grayscale images.
228This can be used to modify negative images to positive or to correct
229images that have the PHOTOMETRIC_INTERPRETATIN tag set incorrectly.
230If the value is black or white, the PHOTOMETRIC_INTERPRETATION tag is set to
231MinIsBlack or MinIsWhite, without altering the image data. If the argument
232is data or both, the data values of the image are modified. Specifying both
233inverts the data and the PHOTOMETRIC_INTERPRETATION tag, whereas using data
234inverts the data but not the PHOTOMETRIC_INTERPRETATION tag.
235No support for modifying the color space of color images in this release.
236.TP
237.B \-H #
238Set the horizontal resolution of output images to #
239expressed in the current units.
240.TP
241.B \-V #
242Set the vertical resolution of the output images to #
243expressed in the current units.
244.TP
245.B \-J #
246Set the horizontal margin of an output page size to #
247expressed in the current units when sectioning image into columns x rows
248subimages using the \-S cols:rows option.
249.TP
250.B \-K #
251Set the vertical margin of an output page size to #
252expressed in the current units when sectioning image into columns x rows
253submiages using the \-S cols:rows option.
254.TP
255.B \-O portrait|landscape|auto
256Set the output orientation of the pages or sections.
257Auto will use the arrangement that requires the fewest pages.
258This option is only meaningful in conjunction with the -P
259option to format an image to fit on a specific paper size.
260.TP
261.B \-P page
262Format the output images to fit on page size paper. Use
263\-P list to show the supported page sizes and dimensions.
264You can define a custom page size by entering the width and length of the
265page in the current units with the following format #.#x#.#.
266.TP
267.B \-S cols:rows
268Divide each image into cols across and rows down equal sections.
269.TP
270.B \-B
271Force output to be written with Big\-Endian byte order.
272This option only has an effect when the output file is created or
273overwritten and not when it is appended to.
274.TP
275.B \-C
276Suppress the use of ``strip chopping'' when reading images
277that have a single strip/tile of uncompressed data.
278.TP
279.B \-c
280Specify the compression to use for data written to the output file:
281.B none
282for no compression,
283.B packbits
284for PackBits compression,
285.B lzw
286for Lempel\-Ziv & Welch compression,
287.B jpeg
288for baseline JPEG compression.
289.B zip
290for Deflate compression,
291.B g3
292for CCITT Group 3 (T.4) compression,
293and
294.B g4
295for CCITT Group 4 (T.6) compression.
296By default
297.I tiffcrop
298will compress data according to the value of the
299.I Compression
300tag found in the source file.
301.IP
302The
303.SM CCITT
304Group 3 and Group 4 compression algorithms can only
305be used with bilevel data.
306.IP
307Group 3 compression can be specified together with several
308T.4\-specific options:
309.B 1d
310for 1\-dimensional encoding,
311.B 2d
312for 2\-dimensional encoding,
313and
314.B fill
315to force each encoded scanline to be zero\-filled so that the
316terminating EOL code lies on a byte boundary.
317Group 3\-specific options are specified by appending a ``:''\-separated
318list to the ``g3'' option; e.g.
319.B "\-c g3:2d:fill"
320to get 2D\-encoded data with byte\-aligned EOL codes.
321.IP
322.SM LZW
323compression can be specified together with a
324.I predictor
325value.
326A predictor value of 2 causes
327each scanline of the output image to undergo horizontal
328differencing before it is encoded; a value
329of 1 forces each scanline to be encoded without differencing.
330LZW\-specific options are specified by appending a ``:''\-separated
331list to the ``lzw'' option; e.g.
332.B "\-c lzw:2"
333for
334.SM LZW
335compression with horizontal differencing.
336.TP
337.B \-f
338Specify the bit fill order to use in writing output data.
339By default,
340.I tiffcrop
341will create a new file with the same fill order as the original.
342Specifying
343.B "\-f lsb2msb"
344will force data to be written with the FillOrder tag set to
345.SM LSB2MSB,
346while
347.B "\-f msb2lsb"
348will force data to be written with the FillOrder tag set to
349.SM MSB2LSB.
350.TP
351.B \-i
352Ignore non\-fatal read errors and continue processing of the input file.
353.TP
354.B \-l
355Specify the length of a tile (in pixels).
356.I Tiffcrop
357attempts to set the tile dimensions so
358that no more than 8 kilobytes of data appear in a tile.
359.TP
360.B \-L
361Force output to be written with Little\-Endian byte order.
362This option only has an effect when the output file is created or
363overwritten and not when it is appended to.
364.TP
365.B \-M
366Suppress the use of memory\-mapped files when reading images.
367.TP
368.B \-p
369Specify the planar configuration to use in writing image data
370that has more than one sample per pixel.
371By default,
372.I tiffcrop
373will create a new file with the same planar configuration as
374the original.
375Specifying
376.B "\-p contig"
377will force data to be written with multi\-sample data packed
378together, while
379.B "\-p separate"
380will force samples to be written in separate planes.
381.TP
382.B \-r
383Specify the number of rows (scanlines) in each strip of data
384written to the output file.
385By default (or when value
386.B 0
387is specified),
388.I tiffcrop
389attempts to set the rows/strip that no more than 8 kilobytes of
390data appear in a strip. If you specify the special value
391.B \-1
392it will results in infinite number of the rows per strip. The entire image
393will be the one strip in that case.
394.TP
395.B \-s
396Force the output file to be written with data organized in strips
397(rather than tiles).
398.TP
399.B \-t
400Force the output file to be written with data organized in tiles
401(rather than strips).
402.TP
403.B \-w
404Specify the width of a tile (in pixels).
405.I tiffcrop
406attempts to set the tile dimensions so
407that no more than 8 kilobytes of data appear in a tile.
408.I tiffcrop
409attempts to set the tile dimensions so
410that no more than 8 kilobytes of data appear in a tile.
411.TP
412Debug and dump facility
413.B \-D opt1:value1,opt2:value2,opt3:value3:opt4:value4
414Display program progress and/or dump raw data to non\-TIFF files.
415Options include the following and must be joined as a comma
416separated list. The use of this option is generally limited to
417program debugging and development of future options. An equal sign
418may be substituted for the colon in option:value pairs.
419.IP
420debug:N Display limited program progress indicators where larger N
421increase the level of detail.
422.IP
423format:txt|raw Format any logged data as ASCII text or raw binary
424values. ASCII text dumps include strings of ones and zeroes representing
425the binary values in the image data plus identifying headers.
426.IP
427level:N Specify the level of detail presented in the dump files.
428This can vary from dumps of the entire input or output image data to dumps
429of data processed by specific functions. Current range of levels is 1 to 3.
430.IP
431input:full\-path\-to\-directory/input\-dumpname
432.IP
433output:full\-path\-to\-directory/output\-dumpname
434.IP
435When dump files are being written, each image will be written to a separate
436file with the name built by adding a numeric sequence value to the dumpname
437and an extension of .txt for ASCII dumps or .bin for binary dumps.
438
439The four debug/dump options are independent, though it makes little sense to
440specify a dump file without specifying a detail level.
441.IP
442Note: Tiffcrop may be compiled with -DDEVELMODE to enable additional very
443 low level debug reporting.
444.SH "EXAMPLES"
445The following concatenates two files and writes the result using
446.SM LZW
447encoding:
448.RS
449.nf
450tiffcrop \-c lzw a.tif b.tif result.tif
451.fi
452.RE
453.PP
454To convert a G3 1d\-encoded
455.SM TIFF
456to a single strip of G4\-encoded data the following might be used:
457.RS
458.nf
459tiffcrop \-c g4 \-r 10000 g3.tif g4.tif
460.fi
461.RE
462(1000 is just a number that is larger than the number of rows in
463the source file.)
464
465To extract a selected set of images from a multi\-image TIFF file
466use the \-N option described above. Thus, to copy the 1st and 3rd
467images of image file "album.tif" to "result.tif":
468.RS
469.nf
470tiffcrop \-N 1,3 album.tif result.tif
471.fi
472.RE
473.PP
474Invert a bilevel image scan of a microfilmed document and crop off margins of
4750.25 inches on the left and right, 0.5 inch on the top, and 0.75 inch on the
476bottom. From the remaining portion of the image, select the second and third
477quarters, ie, one half of the area left from the center to each margin.
478.RS
479tiffcrop \-U in \-m 0.5,0.25,0.75,0.25 \-E left \-Z 2:4,3:4 \-I both MicrofilmNegative.tif MicrofilmPostiveCenter.tif
480.fi
481.RE
482.PP
483Extract only the final image of a large Architectural E sized
484multipage TIFF file and rotate it 90 degrees clockwise while
485reformatting the output to fit on tabloid sized sheets with one
486quarter of an inch on each side:
487.RS
488tiffcrop \-N last \-R 90 \-O auto \-P tabloid \-U in \-J 0.25 \-K 0.25 \-H 300 \-V 300 Big\-PlatMap.tif BigPlatMap\-Tabloid.tif
489.fi
490.RE
491The output images will have a specified resolution of 300 dpi in both
492directions. The orientation of each page will be determined by whichever
493choice requires the fewest pages. To specify a specific orientation, use
494the portrait or landscape option. The paper size option does not resample
495the image. It breaks each original image into a series of smaller images
496that will fit on the target paper size at the specified resolution.
497.fi
498.RE
499.PP
500Extract two regions 2048 pixels wide by 2048 pixels high from each page of
501a multi\-page input file and write each region to a separate output file.
502.RS
503tiffcrop \-U px \-z 1,1,2048,2048:1,2049,2048,4097 \-e separate CheckScans.tiff Check
504.fi
505.RE
506The output file names will use the stem Check with a numeric suffix which is
507incremented for each region of each image, eg Check\-001.tiff, Check\-002.tiff ...
508Check\-NNN.tiff. To produce a unique file for each page of the input image
509with one new image for each region of the input image on that page, change
510the export option to \-e multiple.
511
512.SH "NOTES"
513.PP
514In general, bilevel, grayscale, palette and RGB(A) data with bit depths
515from 1 to 32 bits should work in both interleaved and separate plane
516formats. Unlike tiffcp, tiffcrop can read and write tiled images with
517bits per sample that are not a multiple of 8 in both interleaved and
518separate planar format. Floating point data types are supported at
519bit depts of 16, 24, 32 and 64 bits per sample.
520.PP
521Not all images can be converted from one compression scheme to another.
522Data with some photometric interpretations and/or bit depths are tied to
523specific compression schemes and vice-versa, e.g. Group 3/4 compression
524is only usable for bilevel data. JPEG compression is only usable on 8
525bit per sample data (or 12 bit if
526.I LibTIFF
527was compiled with 12 bit JPEG support). Support for OJPEG compressed
528images is problematic at best. Since OJPEG compression is no longer
529supported for writing images with LibTIFF, these images will be updated
530to the newer JPEG compression when they are copied or processed. This
531may cause the image to appear color shifted or distorted after conversion.
532In some cases, it is possible to remove the original compression from
533image data using the option -cnone.
534.PP
535Tiffcrop does not currently provide options to up or downsample data to
536different bit depths or convert data from one photometric interpretation
537to another, e.g. 16 bits per sample to 8 bits per sample or RGB to grayscale.
538.PP
539Tiffcrop is very loosely derived from code in
540.I tiffcp
541with extensive modifications and additions to support the selection of input
542images and regions and the exporting of them to one or more output files in
543various groupings. The image manipulation routines are entirely new and
544additional ones may be added in the future. It will handle tiled images with
545bit depths that are not a multiple of eight that tiffcp may refuse to read.
546.PP
547.I Tiffcrop
548was designed to handle large files containing many moderate sized images
549with memory usage that is independent of the number of images in the file.
550In order to support compression modes that are not based on individual
551scanlines, e.g. JPEG, it now reads images by strip or tile rather than by
552indvidual scanlines. In addition to the memory required by the input and
553output buffers associated with
554.I LibTIFF
555one or more buffers at least as large as the largest image to be read are
556required. The design favors large volume document processing uses over
557scientific or graphical manipulation of large datasets as might be found
558in research or remote sensing scenarios.
559.SH "SEE ALSO"
560.BR pal2rgb (1),
561.BR tiffinfo (1),
562.BR tiffcmp (1),
563.BR tiffcp (1),
564.BR tiffmedian (1),
565.BR tiffsplit (1),
566.BR libtiff (3TIFF)
567.PP
568Libtiff library home page:
569.BR http://www.remotesensing.org/libtiff/
570