TIFFWRITESCANLINE(3tiff)

πŸ’– TIFFWRITESCANLINE πŸ’–

okay bestie, welcome to the TIFFWriteScanline(3tiff) page β€” this is the LibTIFF girlies' guide to yeeting one whole scanline into an open TIFF file. it's giving "one row at a time, no cap." πŸ¦‹


✨ NAME ✨

TIFFWriteScanline β€” write a scanline to an open TIFF file. that's it, that's the whole vibe. πŸ’…


🌸 SYNOPSIS 🌸

#include <tiffio.h>

int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row, uint16_t sample)

πŸŽ€ DESCRIPTION πŸŽ€

so like, you're writing data to a file at the row you specify. slay. ✨

the sample parameter? it's only used if your data are organized in separate planes, aka PlanarConfiguration = 2. otherwise it's just sitting there being decorative, ngl.

the data you hand over are assumed to be uncompressed and in the native bit- and byte-order of the host machine. the library then does the glow-up: whatever gets written to the file is compressed according to the compression scheme of the current TIFF directory (more on that below, keep reading 🫢).

and here's the cute part: if the current scanline is past the end of the current subfile, the ImageLength field gets automatically increased to include the scanline. the exception is PlanarConfiguration = 2, where ImageLength cannot be changed once the first data are written. periodt. 🚫

and if ImageLength gets increased, the StripOffsets and StripByteCounts fields get similarly enlarged to reflect the data written past the previous end of image. iconic behavior honestly. πŸ‘‘


🧚 NOTES 🧚

  • the library writes encoded data using the native machine byte order. correctly implemented TIFF readers are expected to do any necessary byte-swapping to correctly process image data with BitsPerSample greater than 8. it's a whole teamwork moment. 🀝
  • the library attempts to hide bit-ordering differences between the image and the native machine by converting data from the native machine order.
  • in C++ the sample parameter defaults to 0. πŸ’«
  • once data are written to a file for the current directory, the values of certain tags may not be altered β€” see TIFFSetField() for more information. no take-backsies, bestie. 😭
  • it is not possible to write scanlines to a file that uses a tiled organization. the routine TIFFIsTiled() can be used to determine if the file is organized as tiles or strips. check before you commit, fr fr. πŸ”

πŸ’œ RETURN VALUES πŸ’œ

TIFFWriteScanline() returns -1 if it immediately detects an error, and 1 for a successful write. that's the whole range, she's simple like that. ✨


🌈 DIAGNOSTICS 🌈

all error messages are directed to the TIFFErrorExtR() routine. so when things go sideways, that's who's telling you. πŸ’€

  • %s: File not open for writing: the file was opened for reading, not writing. like girl, you can't write to something you opened read-only. πŸ™ˆ
  • "Can not write scanlines to a tiled image": an attempt was made to write a scanline to a tiled image. the image is assumed to be organized in tiles because the TileWidth and TileLength tags have been set with TIFFSetField().
  • "Compression algorithm does not support random access": data was written in a non-sequential order to a file that uses a compression algorithm and that has RowsPerStrip greater than one. that is, data in the image is to be stored in a compressed form, and with multiple rows packed into a strip. in this case, the library does not support random access to the data. the data should either be written as entire strips, sequentially by rows, or the value of RowsPerStrip should be set to one. pick a lane bestie. πŸ›£οΈ
  • %s: Must set "ImageWidth" before writing data: the image's width has not be set before the first write. see TIFFSetField() for information on how to do this.
  • %s: Must set "PlanarConfiguration" before writing data: the organization of data has not be defined before the first write. see TIFFSetField() for information on how to do this.
  • Can not change "ImageLength" when using separate planes: separate image planes are being used (PlanarConfiguration = 2), but the number of rows has not been specified before the first write. the library supports the dynamic growth of an image only when data are organized in a contiguous manner (PlanarConfiguration = 1).
  • "%d: Sample out of range, max %d": the sample parameter was greater than the value of the SamplesPerPixel tag.
  • %s: No space for strip arrays: there was not enough space for the arrays that hold strip offsets and byte counts. πŸ’”

πŸ¦‹ BUGS πŸ¦‹

writing subsampled YCbCr data does not work correctly because, for PlanarConfiguration = 2 the size of a scanline is not calculated on a per-sample basis, and for PlanarConfiguration = 1 the library does not pack the block-interleaved samples. so yeah, that one's cursed, be aware. 😭


⭐ SEE ALSO ⭐

  • TIFFOpen (3tiff)
  • TIFFWriteEncodedStrip (3tiff)
  • TIFFWriteRawStrip (3tiff)
  • libtiff (3tiff)

πŸ‘‘ AUTHOR πŸ‘‘

LibTIFF contributors πŸ’–


1988-2025, LibTIFF contributors


and that's the tea, bestie πŸ“ β€” this was LibTIFF 4.7, dated Jun 27, 2026, and honestly? she ate. go write those scanlines, you've got this. πŸ’…βœ¨πŸŽ€