react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
280 lines (254 loc) • 7.7 kB
text/typescript
/// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten.
/// Generated from core/schemas/TIFFTypes.yaml
import { ParametricFilter } from '../image_filters/ParametricFilters';
import { DeepPartial, PartiallyConstructible } from '../utils/utils';
/**
TIFF compression type.
- `NONE`:
Dump mode.
- `CCITTRLE`:
CCITT modified Huffman RLE. For binarized images only.
- `CCITT_T4`:
CCITT T.4 (CCITTFAX3, CCITT Group 3 fax encoding, TIFF 6 name). For binarized images only.
- `CCITT_T6`:
CCITT T.6 (CCITTFAX4, CCITT Group 4 fax encoding, TIFF 6 name). For binarized images only.
- `LZW`:
Lempel-Ziv and Welch.
- `JPEG`:
%JPEG DCT compression.
- `CCITTRLEW`:
#1 w/ word alignment. For binarized images only.
- `PACKBITS`:
Macintosh RLE.
- `DEFLATE`:
Deflate compression. Legacy Deflate codec identifier.
- `ADOBE_DEFLATE`:
Deflate compression, as recognized by Adobe. More widely supported.
*/
export type CompressionMode =
| 'NONE'
| 'CCITTRLE'
| 'CCITT_T4'
| 'CCITT_T6'
| 'LZW'
| 'JPEG'
| 'CCITTRLEW'
| 'PACKBITS'
| 'DEFLATE'
| 'ADOBE_DEFLATE';
export const CompressionModeValues: CompressionMode[] = [
'NONE',
'CCITTRLE',
'CCITT_T4',
'CCITT_T6',
'LZW',
'JPEG',
'CCITTRLEW',
'PACKBITS',
'DEFLATE',
'ADOBE_DEFLATE',
];
/**
Binarization behavior to apply when adding pages to a TIFF.
- `DISABLED`:
Do not binarize the image. Image will be stored as a grayscale or color TIFF.
- `ENABLED`:
Binarize the image. Image will be stored as a 1-bit TIFF. If the input image is not black-and-white, a simple thresholding is applied.
- `ENABLED_IF_BINARIZATION_FILTER_SET`:
Same behavior as ENABLED if a binarization filter (TIFFGeneratorParameters.binarizationFilter) is set,
otherwise same behavior as DISABLED. This is the default.
*/
export type Binarization = 'DISABLED' | 'ENABLED' | 'ENABLED_IF_BINARIZATION_FILTER_SET';
export const BinarizationValues: Binarization[] = [
'DISABLED',
'ENABLED',
'ENABLED_IF_BINARIZATION_FILTER_SET',
];
/**
User-defined TIFF field value.
*/
export type UserFieldValue = UserFieldDoubleValue | UserFieldStringValue | UserFieldIntValue;
/** @internal */
export namespace UserFieldValue {
/** @internal */
export function From(source: { [key: string]: any }): UserFieldValue {
const _type = source._type;
switch (_type) {
case 'UserFieldDoubleValue':
return new UserFieldDoubleValue(source);
case 'UserFieldStringValue':
return new UserFieldStringValue(source);
case 'UserFieldIntValue':
return new UserFieldIntValue(source);
default:
throw `Unknown child class name: ${_type}`;
}
}
}
/**
Double value (TIFF_DOUBLE).
*/
export class UserFieldDoubleValue extends PartiallyConstructible {
public readonly _type: 'UserFieldDoubleValue' = 'UserFieldDoubleValue';
/**
Value.
*/
public value: number;
/** @param source {@displayType `DeepPartial<UserFieldDoubleValue>`} */
public constructor(source: DeepPartial<UserFieldDoubleValue> = {}) {
super();
if (source.value !== undefined) {
this.value = source.value;
} else {
throw new Error('value must be present in constructor argument');
}
}
}
/**
ASCII string value (TIFF_ASCII).
*/
export class UserFieldStringValue extends PartiallyConstructible {
public readonly _type: 'UserFieldStringValue' = 'UserFieldStringValue';
/**
Value.
*/
public value: string;
/** @param source {@displayType `DeepPartial<UserFieldStringValue>`} */
public constructor(source: DeepPartial<UserFieldStringValue> = {}) {
super();
if (source.value !== undefined) {
this.value = source.value;
} else {
throw new Error('value must be present in constructor argument');
}
}
}
/**
32-bit int value (TIFF_LONG).
*/
export class UserFieldIntValue extends PartiallyConstructible {
public readonly _type: 'UserFieldIntValue' = 'UserFieldIntValue';
/**
Value.
*/
public value: number;
/** @param source {@displayType `DeepPartial<UserFieldIntValue>`} */
public constructor(source: DeepPartial<UserFieldIntValue> = {}) {
super();
if (source.value !== undefined) {
this.value = source.value;
} else {
throw new Error('value must be present in constructor argument');
}
}
}
/**
User-defined TIFF field.
*/
export class UserField extends PartiallyConstructible {
/**
Numeric tag.
*/
public tag: number;
/**
Field name.
*/
public name: string;
/**
Value.
*/
public value: UserFieldValue;
/** @param source {@displayType `DeepPartial<UserField>`} */
public constructor(source: DeepPartial<UserField> = {}) {
super();
if (source.tag !== undefined) {
this.tag = source.tag;
} else {
throw new Error('tag must be present in constructor argument');
}
if (source.name !== undefined) {
this.name = source.name;
} else {
throw new Error('name must be present in constructor argument');
}
if (source.value !== undefined) {
this.value = UserFieldValue.From(source.value);
} else {
throw new Error('value must be present in constructor argument');
}
}
}
/**
TIFF generator parameters.
*/
export class TiffGeneratorParameters extends PartiallyConstructible {
/**
Compression.
Default is LZW
*/
public compression: CompressionMode = 'LZW';
/**
JPEG quality (TIFFTAG_JPEGQUALITY). Values range from 0 to 100.
Default is 80
*/
public jpegQuality: number = 80;
/**
ZIP/Deflate compression level (TIFFTAG_ZIPQUALITY). Values range from 1 to 9.
Default is 6
*/
public zipCompressionLevel: number = 6;
/**
DPI value.
Default is 72
*/
public dpi: number = 72;
/**
User-defined fields.
*/
public userFields: UserField[] = [];
/**
Filter to apply to the input image when adding pages with binarization.
If set, the filter is applied to the input image and the resulting image is stored as a 1-bit TIFF.
When storing documents it's typically best to use the BINARY_DOCUMENT_OPTIMIZED_COMPRESSION compression mode (CCITT_T6)
instead of the default, as it tends to produce the smallest file sizes.
If not set, simple thresholding is applied to the image, instead.
*/
public binarizationFilter: ParametricFilter | null = null;
/** @param source {@displayType `DeepPartial<TiffGeneratorParameters>`} */
public constructor(source: DeepPartial<TiffGeneratorParameters> = {}) {
super();
if (source.compression !== undefined) {
this.compression = source.compression;
}
if (source.jpegQuality !== undefined) {
this.jpegQuality = source.jpegQuality;
}
if (source.zipCompressionLevel !== undefined) {
this.zipCompressionLevel = source.zipCompressionLevel;
}
if (source.dpi !== undefined) {
this.dpi = source.dpi;
}
if (source.userFields !== undefined) {
this.userFields = source.userFields.map((it: any) => {
return new UserField(it);
});
}
if (source.binarizationFilter !== undefined) {
this.binarizationFilter =
source.binarizationFilter != null ? ParametricFilter.From(source.binarizationFilter) : null;
}
}
}
export namespace TiffGeneratorParameters {
/**
Default compression.
Default is LZW
*/
export const defaultCompression: CompressionMode = 'LZW';
/**
Compression mode typically producing the smallest file sizes for binary (1-bit) document images.
Default is CCITT_T6
*/
export const binaryDocumentOptimizedCompression: CompressionMode = 'CCITT_T6';
}