mirror of
https://github.com/lovell/sharp.git
synced 2025-12-06 03:51:40 +01:00
TypeScript: consolidate a few enum-like properties
This commit is contained in:
parent
ef86a75560
commit
f7c95d1bf0
15
lib/index.d.ts
vendored
15
lib/index.d.ts
vendored
@ -860,6 +860,7 @@ declare namespace sharp {
|
|||||||
| JxlOptions
|
| JxlOptions
|
||||||
| GifOptions
|
| GifOptions
|
||||||
| Jp2Options
|
| Jp2Options
|
||||||
|
| RawOptions
|
||||||
| TiffOptions,
|
| TiffOptions,
|
||||||
): Sharp;
|
): Sharp;
|
||||||
|
|
||||||
@ -1181,6 +1182,10 @@ declare namespace sharp {
|
|||||||
'IFD3'?: ExifDir;
|
'IFD3'?: ExifDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HeifCompression = 'av1' | 'hevc';
|
||||||
|
|
||||||
|
type Unit = 'inch' | 'cm';
|
||||||
|
|
||||||
interface WriteableMetadata {
|
interface WriteableMetadata {
|
||||||
/** Number of pixels per inch (DPI) */
|
/** Number of pixels per inch (DPI) */
|
||||||
density?: number | undefined;
|
density?: number | undefined;
|
||||||
@ -1259,7 +1264,7 @@ declare namespace sharp {
|
|||||||
/** Buffer containing raw TIFFTAG_PHOTOSHOP data, if present */
|
/** Buffer containing raw TIFFTAG_PHOTOSHOP data, if present */
|
||||||
tifftagPhotoshop?: Buffer | undefined;
|
tifftagPhotoshop?: Buffer | undefined;
|
||||||
/** The encoder used to compress an HEIF file, `av1` (AVIF) or `hevc` (HEIC) */
|
/** The encoder used to compress an HEIF file, `av1` (AVIF) or `hevc` (HEIC) */
|
||||||
compression?: 'av1' | 'hevc';
|
compression?: HeifCompression | undefined;
|
||||||
/** Default background colour, if present, for PNG (bKGD) and GIF images */
|
/** Default background colour, if present, for PNG (bKGD) and GIF images */
|
||||||
background?: { r: number; g: number; b: number } | { gray: number };
|
background?: { r: number; g: number; b: number } | { gray: number };
|
||||||
/** Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide */
|
/** Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide */
|
||||||
@ -1267,7 +1272,7 @@ declare namespace sharp {
|
|||||||
/** Number of Sub Image File Directories in an OME-TIFF image */
|
/** Number of Sub Image File Directories in an OME-TIFF image */
|
||||||
subifds?: number | undefined;
|
subifds?: number | undefined;
|
||||||
/** The unit of resolution (density) */
|
/** The unit of resolution (density) */
|
||||||
resolutionUnit?: 'inch' | 'cm' | undefined;
|
resolutionUnit?: Unit | undefined;
|
||||||
/** String containing format for images loaded via *magick */
|
/** String containing format for images loaded via *magick */
|
||||||
formatMagick?: string | undefined;
|
formatMagick?: string | undefined;
|
||||||
/** Array of keyword/text pairs representing PNG text blocks, if present. */
|
/** Array of keyword/text pairs representing PNG text blocks, if present. */
|
||||||
@ -1423,7 +1428,7 @@ declare namespace sharp {
|
|||||||
/** quality, integer 1-100 (optional, default 50) */
|
/** quality, integer 1-100 (optional, default 50) */
|
||||||
quality?: number | undefined;
|
quality?: number | undefined;
|
||||||
/** compression format: av1, hevc (optional, default 'av1') */
|
/** compression format: av1, hevc (optional, default 'av1') */
|
||||||
compression?: 'av1' | 'hevc' | undefined;
|
compression?: HeifCompression | undefined;
|
||||||
/** use lossless compression (optional, default false) */
|
/** use lossless compression (optional, default false) */
|
||||||
lossless?: boolean | undefined;
|
lossless?: boolean | undefined;
|
||||||
/** Level of CPU effort to reduce file size, between 0 (fastest) and 9 (slowest) (optional, default 4) */
|
/** Level of CPU effort to reduce file size, between 0 (fastest) and 9 (slowest) (optional, default 4) */
|
||||||
@ -1481,7 +1486,7 @@ declare namespace sharp {
|
|||||||
/** Write 1-bit images as miniswhite (optional, default false) */
|
/** Write 1-bit images as miniswhite (optional, default false) */
|
||||||
miniswhite?: boolean | undefined;
|
miniswhite?: boolean | undefined;
|
||||||
/** Resolution unit options: inch, cm (optional, default 'inch') */
|
/** Resolution unit options: inch, cm (optional, default 'inch') */
|
||||||
resolutionUnit?: 'inch' | 'cm' | undefined;
|
resolutionUnit?: Unit | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PngOptions extends OutputOptions {
|
interface PngOptions extends OutputOptions {
|
||||||
@ -1606,7 +1611,7 @@ declare namespace sharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface RawOptions {
|
interface RawOptions {
|
||||||
depth?: 'char' | 'uchar' | 'short' | 'ushort' | 'int' | 'uint' | 'float' | 'complex' | 'double' | 'dpcomplex';
|
depth?: keyof DepthEnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
|
/** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
|
||||||
|
|||||||
@ -321,7 +321,7 @@ sharp('input.gif')
|
|||||||
// From https://sharp.pixelplumbing.com/api-output#examples-9
|
// From https://sharp.pixelplumbing.com/api-output#examples-9
|
||||||
// Extract raw RGB pixel data from JPEG input
|
// Extract raw RGB pixel data from JPEG input
|
||||||
sharp('input.jpg')
|
sharp('input.jpg')
|
||||||
.raw()
|
.raw({ depth: 'ushort' })
|
||||||
.toBuffer({ resolveWithObject: true })
|
.toBuffer({ resolveWithObject: true })
|
||||||
.then(({ data, info }) => {
|
.then(({ data, info }) => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user