toTiffImageSpec static method
Builds a TiffImageSpec for writing image out as an 8-bit TIFF page
(RGB, or RGBA if keepAlpha is true and image has an alpha channel).
compression/predictor are passed straight through to the spec —
see TiffImageSpec for the accepted values.
Implementation
static TiffImageSpec toTiffImageSpec(
img.Image image, {
bool keepAlpha = false,
int compression = 1,
int predictor = 1,
int? rowsPerStrip,
int? tileWidth,
int? tileLength,
}) {
final useAlpha = keepAlpha && image.hasAlpha;
final samples = image.getBytes(
order: useAlpha ? img.ChannelOrder.rgba : img.ChannelOrder.rgb,
);
return TiffImageSpec(
width: image.width,
height: image.height,
samplesPerPixel: useAlpha ? 4 : 3,
bitsPerSample: 8,
photometric: TiffPhotometric.rgb,
samples: samples,
compression: compression,
predictor: predictor,
rowsPerStrip: rowsPerStrip,
tileWidth: tileWidth,
tileLength: tileLength,
);
}