TIFFCROP(1)

πŸ’– TIFFCROP πŸ’–

okay bestie, buckle UP, because this is tiffcrop from the LibTIFF family and she is busy β€” like, main character with seventeen side quests busy. select, copy, crop, convert, extract, and/or process one or more TIFF files. that's the whole vibe. let's get into it πŸ¦‹

✨ NAME ✨

tiffcrop β€” select, copy, crop, convert, extract, and/or process one or more TIFF files


🌸 SYNOPSIS 🌸

tiffcrop [ options ] src1.tif … srcN.tif dst.tif

like. she takes a bunch of source files and one destination file. that's the shape of it. πŸŽ€


πŸ’… DESCRIPTION πŸ’…

okay so here's the tea. tiffcrop processes one or more files created according to the Tag Image File Format, Revision 6.0, specification into one or more TIFF file(s). it's the girl who shows up with a plan and a laminator.

she's most often used to extract portions of an image for processing with bar code recognizer or OCR software β€” specifically when that software cannot restrict the region of interest to a specific portion of the image β€” or to improve efficiency when the regions of interest must be rotated. she can also be used to subdivide all or part of a processed image into smaller sections and export individual images or sections of images as separate files or separate images within one or more files derived from the original input image or images. multi-tasking queen. no cap. πŸ‘‘

the available functions can be grouped broadly into three classes:

  1. the pickers β€” those that select individual images or sections of images from the input files. the options -N for sequences or lists of individual images in the input files, -Z for zones, -z for regions, -X and -Y for fixed sized selections, -m for margins, -U for units, and -E for edge reference provide a variety of ways to specify portions of the input image. so many little scissors βœ‚οΈ
  2. the packers β€” those that allow the individual images or selections to be exported to one or more output files in different groupings and control the organization of the data in the output images. the options -P for page size grouping, -S for subdivision into columns and rows and -e for export mode options that produce one or more files from each input image. the options -r, -s, -t, -w control strip and tile format and sizes while -B, -L, -c, -f modify the endian addressing scheme, the compression options, and the bit fill sequence of images as they are written. organization is self care fr fr πŸ“¦
  3. the doers β€” those that perform some action on each image that is selected from the input file. the options include -R for rotate, -I for inversion of the photometric interpretation and/or data values, and -F to flip (mirror) the image horizontally or vertically. slay.

πŸŒ€ the order of operations (this part matters, bestie)

functions are applied to the input image(s) in the following order: cropping, fixed area extraction, zone and region extraction, inversion, mirroring, rotation.

functions are applied to the output image(s) in the following order: export mode options for grouping zones, regions, or images into one or more files, or row and column divisions with output margins, or page size divisions with page orientation options.

finally, strip, tile, byte order, output resolution, and compression options are applied to all output images.


🌈 the general behavior

the output file(s) may be organized and compressed using a different algorithm from the input files. by default, tiffcrop will copy all the understood tags in a TIFF directory of an input file to the associated directory in the output file. options can be used to force the resultant image to be written as strips or tiles of data, respectively.

tiffcrop can be used to reorganize the storage characteristics of data in a file, and to reorganize, extract, rotate, and otherwise process the image data as specified at the same time β€” whereas tiffcp does not alter the image data within the file. so like, tiffcrop is the one who actually touches the pixels, and tiffcp is the one who just moves the boxes. πŸ’€

using the options for selecting individual input images and the options for exporting images and/or segments defined as zones or regions of each input image, tiffcrop can perform the functions of tiffcp and tiffsplit in a single pass while applying multiple operations to individual selections or images. one pass, three jobs, iconic behavior.


✨ OPTIONS ✨

  • -h β€” display the syntax summary for tiffcrop. the "help me bestie" button 🫢
  • -v β€” report the current version and last modification date for tiffcrop. receipts. 🧾
  • -N odd|even|#,#-#,#|last β€” specify one or more series or range(s) of images within each file to process. the words odd or even may be used to specify all odd or even numbered images counting from one. note that internally, TIFF images are numbered from zero rather than one, but since this convention is not obvious to most users, tiffcrop used 1 to specify the first image in a multipage file. the word last may be used in place of a number in the sequence to indicate the final image in the file without knowing how many images there are. ranges of images may be specified with a dash and multiple sets can be indicated by joining them in a comma-separated list. eg. use -N 1,5-7,last to process the 1st, 5th through 7th, and final image in the file. so forgiving of our counting habits πŸ₯Ή
  • -E top|bottom|left|right β€” specify the top, bottom, left, or right edge as the reference from which to calculate the width and length of crop regions or sequence of positions for zones. when used with the -e option for exporting zones or regions, the reference edge determines how composite images are arranged. using -E left or -E right causes successive zones or regions to be merged horizontally whereas using -E top or -E bottom causes successive zones or regions to be arranged vertically. this option has no effect on export layout when multiple zones or regions are not being exported to composite images. edges may be abbreviated to the first letter. so -E l is legally a whole sentence. ✨
  • -e combined|divided|image|multiple|separate β€” specify the export mode for images and selections from input images. the final filename on the command line is considered to be the destination file or filename stem for automatically generated sequences of files. modes may be abbreviated to the first letter.

πŸŽ€ EXPORT MODES πŸŽ€

the girlies need to know their options, so here they are, one by one:

  • combined β€” all images and selections are written to a single file with multiple selections from one image combined into a single image (default). the cozy everything-in-one-bowl mode πŸ“
  • divided β€” all images and selections are written to a single file with each selection from one image written to a new image. one file, but every selection gets its own page. ✨
  • image β€” each input image is written to a new file (numeric filename sequence) with multiple selections from the image combined into one image. new file per input, selections snuggled together. πŸŽ€
  • multiple β€” each input image is written to a new file (numeric filename sequence) with each selection from the image written to a new image. new file per input, every selection separate. so many files bestie. πŸ’€
  • separate β€” individual selections from each image are written to separate files. maximum chaos, maximum control. 🌈

πŸ¦‹ the rest of the options

  • -U in|cm|px β€” specify the type of units to apply to dimensions for margins and crop regions for input and output images. inches or centimeters are converted to pixels using the resolution unit specified in the TIFF file (which defaults to inches if not specified in the IFD). she does the math for you, you're welcome. πŸ’œ
  • -m top,left,bottom,right β€” specify margins to be removed from the input image. the order must be top, left, bottom, right with only commas separating the elements of the list. margins are scaled according to the current units and removed before any other extractions are computed. wrong order = wrong crop, so like, respect the order bestie 😭
  • -X # β€” set the horizontal (X-axis) dimension of a region to extract relative to the specified origin reference. if the origin is the top or bottom edge, the X axis value will be assumed to start at the left edge.
  • -Y # β€” set the vertical (Y-axis) dimension of a region to extract relative to the specified origin reference. if the origin is the left or right edge, the Y axis value will be assumed to start at the top.
  • -Z #:#,#:# β€” specify zones of the image designated as position X of Y equal sized portions measured from the reference edge, eg 1:3 would be first third of the image starting from the reference edge minus any margins specified for the confining edges. multiple zones can be specified as a comma separated list but they must reference the same edge. to extract the top quarter and the bottom third of an image you would use -Z 1:4,3:3. like slicing a cake and calling it geometry πŸŽ‚
  • -z x1,y1,x2,y2: ... :xN,yN,xN+1,yN+1 β€” specify a series of coordinates to define regions for processing and exporting. the coordinates represent the top left and lower right corners of each region in the current units, eg inch, cm, or pixels. pixels are counted from one to width or height and inches or cm are calculated from image resolution data.

each colon delimited series of four values represents the horizontal and vertical offsets from the top and left edges of the image, regardless of the edge specified with the -E option. the first and third values represent the horizontal offsets of the corner points from the left edge while the second and fourth values represent the vertical offsets from the top edge.

  • -F horiz|vert β€” flip the image (or just the extracted region) like a mirror. horiz for left-right, vert for upside-down. πŸͺž
  • -R 90|180|270 β€” rotate the image or the extracted region 90, 180, or 270 degrees clockwise. periodt. πŸ”„
  • -I [black|white|data|both] β€” invert the color space, bestie. like dark becomes light for bilevel and grayscale images. this is the move for turning a negative into a positive, or for fixing an image whose PHOTOMETRIC_INTERPRETATION tag got set all wrong. here's the tea tho:
    • if the value is black or white, the PHOTOMETRIC_INTERPRETATION tag gets set to MinIsBlack or MinIsWhite, and the image data is not touched at all.
    • if the argument is data or both, the actual data values of the image get modified.
    • specifying both inverts the data and the PHOTOMETRIC_INTERPRETATION tag, whereas data inverts the data but leaves the PHOTOMETRIC_INTERPRETATION tag alone.
no support for modifying the color space of color images in this release. 😭 grayscale girlies only.
  • -H # β€” set the horizontal resolution of output images to #, expressed in the current units. πŸ“
  • -V # β€” set the vertical resolution of the output images to #, expressed in the current units. πŸ“
  • -J # β€” set the horizontal margin of an output page size to #, expressed in the current units, for when you're sectioning an image into columns Γ— rows subimages with the -S cols:rows option.
  • -K # β€” set the vertical margin of an output page size to #, expressed in the current units, for when you're sectioning an image into columns Γ— rows subimages with the -S cols:rows option.
  • -O portrait|landscape|auto β€” set the output orientation of the pages or sections. auto picks whichever arrangement needs the fewest pages (it's giving efficiency queen πŸ‘‘). this option only means anything when you pair it with -P to format an image onto a specific paper size.
  • -P page β€” format the output images to fit on page-size paper. run -P list to see all the supported page sizes and their dimensions. you can also define a custom page size by entering the width and length of the page in the current units in this exact format: #.#x#.# ✨
  • -S cols:rows β€” divide each image into cols across and rows down, in equal sections. 🍰
  • -B β€” force the output to be written with Big-Endian byte order. heads up: this only does anything when the output file is created or overwritten β€” not when it's appended to.
  • -C β€” suppress the use of "strip chopping" when reading images that have a single strip/tile of uncompressed data.
  • -c β€” specify the compression to use for data written to the output file:
    • -c none for no compression
    • -c packbits for PackBits compression
    • -c lzw for Lempel-Ziv & Welch compression
    • -c jpeg for baseline JPEG compression
    • -c zip for Deflate compression
    • -c g3 for CCITT Group 3 (T.4) compression
    • -c g4 for CCITT Group 4 (T.6) compression

by default, tiffcrop compresses data according to the value of the Compression tag found in the source file.

the CCITT Group 3 and Group 4 compression algorithms can only be used with bilevel data. no exceptions, bestie.

Group 3 compression can be specified together with several T.4-specific options:

  • 1d for 1-dimensional encoding
  • 2d for 2-dimensional encoding
  • fill to force each encoded scanline to be zero-filled so that the terminating EOL code lies on a byte boundary

Group 3-specific options are specified by appending a :-separated list to the g3 option; e.g. -c g3:2d:fill to get 2D-encoded data with byte-aligned EOL codes. πŸŽ€

LZW compression can be specified together with a predictor value. a predictor value of 2 causes each scanline of the output image to undergo horizontal differencing before it's encoded; a value of 1 forces each scanline to be encoded without differencing. LZW-specific options are specified by appending a :-separated list to the lzw option; e.g. -c lzw:2 for LZW compression with horizontal differencing. πŸ’…

  • -f β€” specify the bit fill order to use when writing output data. by default, tiffcrop creates a new file with the same fill order as the original. specifying -f lsb2msb forces data to be written with the FillOrder tag set to LSB2MSB, while -f msb2lsb forces data to be written with the FillOrder tag set to MSB2LSB.
  • -i β€” ignore non-fatal read errors and keep processing the input file. it's giving "we move." 🫢
  • -k size β€” set the maximum memory allocation size (in MiB). the default is 256MiB. set it to 0 to disable the limit entirely. 🧠
  • -l β€” specify the length of a tile (in pixels). tiffcrop attempts to set the tile dimensions so that no more than 8 kilobytes of data appear in a tile.
  • -L β€” force the output to be written with Little-Endian byte order. same rule as -B: this only has an effect when the output file is created or overwritten, not when it's appended to.
  • -M β€” suppress the use of memory-mapped files when reading images.
  • -p β€” specify the planar configuration to use when writing image data that has more than one sample per pixel. by default, tiffcrop creates a new file with the same planar configuration as the original. specifying -p contig forces data to be written with multi-sample data packed together, while -p separate forces samples to be written in separate planes. 🌈
  • -r β€” specify the number of rows (scanlines) in each strip of data written to the output file. by default (or when the value 0 is specified), tiffcrop attempts to set the rows/strip so that no more than 8 kilobytes of data appear in a strip. if you specify the special value -1, it results in an infinite number of rows per strip β€” the entire image becomes the one strip in that case. πŸ’€
  • -s β€” force the output file to be written with data organized in strips (rather than tiles).
  • -t β€” force the output file to be written with data organized in tiles (rather than strips).
  • -w β€” specify the width of a tile (in pixels). tiffcrop attempts to set the tile dimensions so that no more than 8 kilobytes of data appear in a tile.
  • -D opt1:value1,opt2:value2,opt3:value3:opt4:value4 β€” the debug and dump facility. πŸ”

display program progress and/or dump raw data to non-TIFF files. the options below must be joined as a comma separated list. the use of this option is generally limited to program debugging and development of future options. an equal sign may be substituted for the colon in option:value pairs.

  • debug:N: β€” display limited program progress indicators, where a larger N increases the level of detail.
  • format:txt|raw: β€” format any logged data as ASCII text or raw binary values. ASCII text dumps include strings of ones and zeroes representing the binary values in the image data, plus identifying headers.
  • level:N: β€” specify the level of detail presented in the dump files. this can vary from dumps of the entire input or output image data, to dumps of data processed by specific functions. current range of levels is 1 to 3.
  • input:full-path-to-directory/input-dumpname:
  • output:full-path-to-directory/output-dumpname: β€” when dump files are being written, each image will be written to a separate file with the name built by adding a numeric sequence value to the dumpname, plus an extension of .txt for ASCII dumps or .bin for binary dumps.

the four debug/dump options are independent, though it makes little sense to specify a dump file without specifying a detail level.

note: tiffcrop may be compiled with -DDEVELMODE to enable additional very low level debug reporting. deep lore. iykyk.

however, not all option combinations are permitted. πŸ™…β€β™€οΈ

note 1: the (-X|-Y), -Z, -z and -S options are mutually exclusive. in no case should the options be applied to a given selection successively.
note 2: any of the -X, -Y, -Z and -z options together with other PAGE_MODE_x options such as -H, -V, -P, -J or -K are not supported and may cause buffer overflows. ok that's actually scary. don't do it. 😭

✨ EXAMPLES ✨

the following concatenates two files and writes the result using LZW encoding:

tiffcrop -c lzw a.tif b.tif result.tif

to convert a G3 1d-encoded TIFF to a single strip of G4-encoded data, the following might be used:

tiffcrop -c g4 -r 10000 g3.tif g4.tif

(1000 is just a number that is larger than the number of rows in the source file.)


to extract a selected set of images from a multi-image TIFF file, use the -N option described above. so to copy the 1st and 3rd images of image file album.tif to result.tif:

tiffcrop -N 1,3 album.tif result.tif

invert a bilevel image scan of a microfilmed document and crop off margins of 0.25 inches on the left and right, 0.5 inch on the top, and 0.75 inch on the bottom. from the remaining portion of the image, select the second and third quarters β€” ie, one half of the area left from the center to each margin:

tiffcrop -U in -m 0.5,0.25,0.75,0.25 -E left -Z 2:4,3:4 -I both MicrofilmNegative.tif MicrofilmPostiveCenter.tif

extract only the final image of a large Architectural E sized multipage TIFF file and rotate it 90 degrees clockwise, while reformatting the output to fit on tabloid sized sheets with one quarter of an inch on each side:

tiffcrop -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

the output images will have a specified resolution of 300 dpi in both directions. the orientation of each page will be determined by whichever choice requires the fewest pages. to specify a specific orientation, use the portrait or landscape option. the paper size option does not resample the image β€” it breaks each original image into a series of smaller images that will fit on the target paper size at the specified resolution. πŸ“„βœ¨


extract two regions 2048 pixels wide by 2048 pixels high from each page of a multi-page input file, and write each region to a separate output file:

tiffcrop -U px -z 1,1,2048,2048:1,2049,2048,4097 -e separate  CheckScans.tiff Check

the output file names will use the stem Check with a numeric suffix which is incremented for each region of each image, eg Check-001.tiff, Check-002.tiff … Check-NNN.tiff. to produce a unique file for each page of the input image, with one new image for each region of the input image on that page, change the export option to -e multiple. πŸŽ€

πŸ’­ NOTES πŸ’­

okay bestie, story time, this is the part where I tell you what actually works and what will absolutely humble you πŸ’€

In general, bilevel, grayscale, palette and RGB(A) data with bit depths from 1 to 32 bits should work in both interleaved and separate plane formats. Yes, all of it. We love range. ✨

Unlike tiffcp, tiffcrop can read and write tiled images with bits per sample that are not a multiple of 8 β€” in both interleaved and separate planar format. That's the glow-up, that's the difference, no cap. 🫢 Floating point data types are supported at bit depths of 16, 24, 32 and 64 bits per sample. Slay.


Not all images can be converted from one compression scheme to another. 🚨 Data with some photometric interpretations and/or bit depths are tied to specific compression schemes and vice-versa, e.g. Group 3/4 compression is only usable for bilevel data. JPEG compression is only usable on 8 bit per sample data (or 12 bit if libtiff was compiled with 12 bit JPEG support). It's giving "these two are dating, you can't separate them." πŸ’…

Support for OJPEG compressed images is problematic at best. 😭 That's not me being dramatic, that's the manual being dramatic, and honestly? fair.

Since OJPEG compression is no longer supported for writing images with LibTIFF, these images will be updated to the newer JPEG compression when they are copied or processed. This may cause the image to appear color shifted or distorted after conversion.

so like… be aware, bestie. 🫣 In some cases, it is possible to remove the original compression from image data using the option -c none. ✨ That's your escape hatch, iykyk.


tiffcrop does not currently provide options to up or downsample data to different bit depths or convert data from one photometric interpretation to another, e.g. 16 bits per sample to 8 bits per sample or RGB to grayscale. So no, she will not glow you down to grayscale. She said "wear your own outfit." πŸ’…


tiffcrop is very loosely derived from code in tiffcp with extensive modifications and additions to support the selection of input images and regions and the exporting of them to one or more output files in various groupings. The image manipulation routines are entirely new and additional ones may be added in the future πŸ‘€ (not a promise, just a vibe). It will handle tiled images with bit depths that are not a multiple of eight that tiffcp may refuse to read. main character energy fr fr πŸ‘‘


tiffcrop was designed to handle large files containing many moderate sized images with memory usage that is independent of the number of images in the file. 🧚 That's the whole point of her, bestie.

In order to support compression modes that are not based on individual scanlines, e.g. JPEG, it now reads images by strip or tile rather than by individual scanlines. In addition to the memory required by the input and output buffers associated with libtiff one or more buffers at least as large as the largest image to be read are required. So budget accordingly, okay? 😭

The design favors large volume document processing uses over scientific or graphical manipulation of large datasets as might be found in research or remote sensing scenarios. She's built for the grind, not the telescope. πŸ”­πŸ’€


πŸ¦‹ SEE ALSO πŸ¦‹

the squad, the whole friend group, go say hi:

  • pal2rgb (1)
  • tiffinfo (1)
  • tiffcmp (1)
  • tiffcp (1)
  • tiffmedian (1)
  • tiffsplit (1)
  • libtiff (3tiff)

πŸ’œ AUTHOR πŸ’œ

LibTIFF contributors β€” the collective, the committee, the it-girls working in shifts 🫢✨


1988-2025, LibTIFF contributors


okay that's the whole page, we did it, we made it to the end πŸπŸ’– this lil queen is TIFFCROP(1) from LibTIFF version 4.7, dated Jun 27, 2026 β€” go crop something iconic, bestie, and don't forget to close your file descriptors on the way out πŸ’…πŸŒΈ

πŸ“¦ where this page comes from