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