AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
January 2008

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2008.01.21 19:38 "How to clip an image with LibTiff", by <erez.har-tal@walgreens.com>
2008.01.22 10:24 "Re: How to clip an image with LibTiff", by Gerben Vos
2008.01.22 10:38 "Q: Change single pixels in a tiled Tiffs", by Timur Ametov
2008.01.23 20:18 "Change single pixels in a tiled Tiff-image", by Timur Ametov
2008.01.24 12:14 "Re: Change single pixels in a tiled Tiff-image", by Andrey Kiselev
2008.01.24 12:35 "Re: Change single pixels in a tiled Tiff-image", by Andy Cave
2008.01.22 20:39 "Re: How to clip an image with LibTiff", by Andrey Kiselev
2008.01.24 16:09 "How to clip an image with Tiffcrop", by Beppe Costagliola
2008.01.22 22:30 "Re: Tiff Digest, Vol 44, Issue 8, Cropping faxes", by Richard Nolde
2008.01.22 23:59 "Re: Tiff Digest, Vol 44, Issue 8, Cropping faxes", by Andy Cave
2008.01.23 00:39 "Tiff Digest, Vol 44, Issue 8, Cropping faxes", by Richard Nolde
2008.01.23 10:51 "Re: Tiff Digest, Vol 44, Issue 8, Cropping faxes", by Andy Cave
2008.01.24 05:23 "TIffcrop might be called tiffextract", by Richard Nolde
2008.01.24 12:07 "Re: TIffcrop might be called tiffextract", by Andrey Kiselev
2008.01.24 12:32 "Re: TIffcrop might be called tiffextract", by Andy Cave
2008.01.25 05:52 "Tiffcrop and tiff2pdf", by Richard Nolde
2008.01.25 09:25 "Re: Tiffcrop and tiff2pdf", by Beppe Costagliola
2008.01.25 14:41 "Re: Tiffcrop and tiff2pdf", by Beppe Costagliola
2008.01.26 00:03 "Re: Tiffcrop and tiff2pdf", by Richard Nolde

2008.01.22 10:24 "Re: How to clip an image with LibTiff", by Gerben Vos

Erez.Har-Tal@Walgreens.com wrote:

> We deal with faxes in standard mode (204X98 dpi) or fine mode
> (204X198 dpi) saved with compression of type G3 1D.

> I need to write a utility that clips the first X rows (pixel) from
> the top of the tiff image and last X rows from the bottom of the tiff
> image. We will save it to a new tiff image with G3 compression in the
> height of 2X pixels. The first X rows will be the top of the new image
> and the last X rows will be the bottom of the image. The operation to
> clip the image, should not alter the image nor do any thing that would
> damage the image.

> Is it doable using libtiff on Unix ? Any help and direction will be
> highly appreciated. Doable using other open source libraries ?

Because you know in advance that the input TIFFs will be strip-based
(instead of tile-based) and black-and-white, this is quite easy to do
with libtiff.

You'll get something like this (this is more pseudo-code than real
code, error checking has been omitted):

TIFF *in = TIFFOpen("input.tif", "r");
TIFF *out = TIFFOpen("output.tif", "w");
// Maybe read some headers from "in" to check validity?
// ...
uint32 height;
TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
if (height < 2 * x) {
	// error out
}
uint32 linesize = TIFFScanlineSize(in);
tdata_t scanline = _TIFFmalloc(linesize);

// Write necessary headers to "out".
TIFFSetField(out, ...);
TIFFSetField(out, TIFFTAG_IMAGELENGTH, 2 * x);
TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX3);
// ...

for (uint32 i = 0; i < x; ++i) {
	TIFFReadScanline(in, i, scanline, 0);
	TIFFWriteScanline(out, i, scanline, 0);
}
for (uint32 i = height - x; i < height; ++i) {
	TIFFReadScanline(in, i, scanline, 0);
	TIFFWriteScanline(out, i, scanline, 0);
}

_TIFFfree(scanline);
TIFFClose(in);
TIFFClose(out);

Read the documentation for the exact headers you need to write. Also
look at the included utility programs for inspiration. Obviously, I
haven't tested any of the above code and give no guarantees whatsoever.

					Gerben Vos.