Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1/**2 * Copyright 2017 François Nguyen and others.3 *4 * Billy Kwok <https://github.com/billykwok>5 * Bradley Odell <https://github.com/BTOdell>6 * Espen Hovlandsdal <https://github.com/rexxars>7 * Floris de Bijl <https://github.com/Fdebijl>8 * François Nguyen <https://github.com/phurytw>9 * Jamie Woodbury <https://github.com/JamieWoodbury>10 * Wooseop Kim <https://github.com/wooseopkim>11 *12 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated13 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation14 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to15 * permit persons to whom the Software is furnished to do so, subject to the following conditions:16 *17 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of18 * the Software.19 *20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE21 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR22 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24 */25 26// SPDX-License-Identifier: MIT27 28/// <reference types="node" />29 30declare type Duplex = import('node:stream').Duplex;31declare type ColorLike = import('@img/colour').ColorLike;32 33//#region Constructor functions34 35/**36 * Creates a sharp instance from an image37 * @param input Buffer containing JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF or raw pixel image data, or String containing the path to an JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image file.38 * @param options Object with optional attributes.39 * @throws {Error} Invalid parameters40 * @returns A sharp instance that can be used to chain operations41 */42 43/** Object containing nested boolean values representing the available input and output formats/methods. */44export const format: FormatEnum;45 46/** An Object containing the version numbers of sharp, libvips and its dependencies. */47export const versions: {48 aom?: string | undefined;49 archive?: string | undefined;50 cairo?: string | undefined;51 cgif?: string | undefined;52 exif?: string | undefined;53 expat?: string | undefined;54 ffi?: string | undefined;55 fontconfig?: string | undefined;56 freetype?: string | undefined;57 fribidi?: string | undefined;58 glib?: string | undefined;59 harfbuzz?: string | undefined;60 heif?: string | undefined;61 highway?: string | undefined;62 imagequant?: string | undefined;63 lcms?: string | undefined;64 mozjpeg?: string | undefined;65 pango?: string | undefined;66 pixman?: string | undefined;67 png?: string | undefined;68 "proxy-libintl"?: string | undefined;69 rsvg?: string | undefined;70 sharp: string;71 spng?: string | undefined;72 tiff?: string | undefined;73 vips: string;74 webp?: string | undefined;75 xml?: string | undefined;76 "zlib-ng"?: string | undefined;77};78 79/** An Object containing the available interpolators and their proper values */80export const interpolators: Interpolators;81 82/** An EventEmitter that emits a change event when a task is either queued, waiting for libuv to provide a worker thread, complete */83export const queue: NodeJS.EventEmitter;84 85//#endregion86 87//#region Utility functions88 89/**90 * Gets or, when options are provided, sets the limits of libvips' operation cache.91 * Existing entries in the cache will be trimmed after any change in limits.92 * This method always returns cache statistics, useful for determining how much working memory is required for a particular task.93 * @param options Object with the following attributes, or Boolean where true uses default cache settings and false removes all caching (optional, default true)94 * @returns The cache results.95 */96export function cache(options?: boolean | CacheOptions): CacheResult;97 98/**99 * Gets or sets the number of threads libvips' should create to process each image.100 * The default value is the number of CPU cores. A value of 0 will reset to this default.101 * The maximum number of images that can be processed in parallel is limited by libuv's UV_THREADPOOL_SIZE environment variable.102 * @param concurrency The new concurrency value.103 * @returns The current concurrency value.104 */105export function concurrency(concurrency?: number): number;106 107/**108 * Provides access to internal task counters.109 * @returns Object containing task counters110 */111export function counters(): SharpCounters;112 113/**114 * Get and set use of SIMD vector unit instructions. Requires libvips to have been compiled with highway support.115 * Improves the performance of resize, blur and sharpen operations by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.116 * @param enable enable or disable use of SIMD vector unit instructions117 * @returns true if usage of SIMD vector unit instructions is enabled118 */119export function simd(enable?: boolean): boolean;120 121/**122 * Block libvips operations at runtime.123 *124 * This is in addition to the `VIPS_BLOCK_UNTRUSTED` environment variable,125 * which when set will block all "untrusted" operations.126 *127 * @since 0.32.4128 *129 * @example <caption>Block all TIFF input.</caption>130 * block({131 * operation: ['VipsForeignLoadTiff']132 * });133 *134 * @param {Object} options135 * @param {Array<string>} options.operation - List of libvips low-level operation names to block.136 */137export function block(options: { operation: string[] }): void;138 139/**140 * Unblock libvips operations at runtime.141 *142 * This is useful for defining a list of allowed operations.143 *144 * @since 0.32.4145 *146 * @example <caption>Block all input except WebP from the filesystem.</caption>147 * block({148 * operation: ['VipsForeignLoad']149 * });150 * unblock({151 * operation: ['VipsForeignLoadWebpFile']152 * });153 *154 * @example <caption>Block all input except JPEG and PNG from a Buffer or Stream.</caption>155 * block({156 * operation: ['VipsForeignLoad']157 * });158 * unblock({159 * operation: ['VipsForeignLoadJpegBuffer', 'VipsForeignLoadPngBuffer']160 * });161 *162 * @param {Object} options163 * @param {Array<string>} options.operation - List of libvips low-level operation names to unblock.164 */165export function unblock(options: { operation: string[] }): void;166 167//#endregion168 169export const gravity: GravityEnum;170export const strategy: StrategyEnum;171export const kernel: KernelEnum;172export const fit: FitEnum;173export const bool: BoolEnum;174 175export interface Sharp extends Duplex {176 //#region Channel functions177 178 /**179 * Remove alpha channel, if any. This is a no-op if the image does not have an alpha channel.180 * @returns A sharp instance that can be used to chain operations181 */182 removeAlpha(): Sharp;183 184 /**185 * Ensure alpha channel, if missing. The added alpha channel will be fully opaque. This is a no-op if the image already has an alpha channel.186 * @param alpha transparency level (0=fully-transparent, 1=fully-opaque) (optional, default 1).187 * @returns A sharp instance that can be used to chain operations188 */189 ensureAlpha(alpha?: number): Sharp;190 191 /**192 * Extract a single channel from a multi-channel image.193 * @param channel zero-indexed channel/band number to extract, or red, green, blue or alpha.194 * @throws {Error} Invalid channel195 * @returns A sharp instance that can be used to chain operations196 */197 extractChannel(channel: 0 | 1 | 2 | 3 | 'red' | 'green' | 'blue' | 'alpha'): Sharp;198 199 /**200 * Join one or more channels to the image. The meaning of the added channels depends on the output colourspace, set with toColourspace().201 * By default the output image will be web-friendly sRGB, with additional channels interpreted as alpha channels. Channel ordering follows vips convention:202 * - sRGB: 0: Red, 1: Green, 2: Blue, 3: Alpha.203 * - CMYK: 0: Magenta, 1: Cyan, 2: Yellow, 3: Black, 4: Alpha.204 *205 * Buffers may be any of the image formats supported by 206 * For raw pixel input, the options object should contain a raw attribute, which follows the format of the attribute of the same name in the sharp() constructor.207 * @param images one or more images (file paths, Buffers).208 * @param options image options, see sharp() constructor.209 * @throws {Error} Invalid parameters210 * @returns A sharp instance that can be used to chain operations211 */212 joinChannel(images: string | Buffer | ArrayLike<string | Buffer>, options?: SharpOptions): Sharp;213 214 /**215 * Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image.216 * @param boolOp one of "and", "or" or "eor" to perform that bitwise operation, like the C logic operators &, | and ^ respectively.217 * @throws {Error} Invalid parameters218 * @returns A sharp instance that can be used to chain operations219 */220 bandbool(boolOp: keyof BoolEnum): Sharp;221 222 //#endregion223 224 //#region Color functions225 226 /**227 * Tint the image using the provided colour.228 * An alpha channel may be present and will be unchanged by the operation.229 * @param tint Parsed by the color module.230 * @returns A sharp instance that can be used to chain operations231 */232 tint(tint: ColorLike): Sharp;233 234 /**235 * Convert to 8-bit greyscale; 256 shades of grey.236 * This is a linear operation.237 * If the input image is in a non-linear colour space such as sRGB, use gamma() with greyscale() for the best results.238 * By default the output image will be web-friendly sRGB and contain three (identical) colour channels.239 * This may be overridden by other sharp operations such as toColourspace('b-w'), which will produce an output image containing one colour channel.240 * An alpha channel may be present, and will be unchanged by the operation.241 * @param greyscale true to enable and false to disable (defaults to true)242 * @returns A sharp instance that can be used to chain operations243 */244 greyscale(greyscale?: boolean): Sharp;245 246 /**247 * Alternative spelling of greyscale().248 * @param grayscale true to enable and false to disable (defaults to true)249 * @returns A sharp instance that can be used to chain operations250 */251 grayscale(grayscale?: boolean): Sharp;252 253 /**254 * Set the pipeline colourspace.255 * The input image will be converted to the provided colourspace at the start of the pipeline.256 * All operations will use this colourspace before converting to the output colourspace, as defined by toColourspace.257 *258 * @param colourspace pipeline colourspace e.g. rgb16, scrgb, lab, grey16 ...259 * @throws {Error} Invalid parameters260 * @returns A sharp instance that can be used to chain operations261 */262 pipelineColourspace(colourspace?: string): Sharp;263 264 /**265 * Alternative spelling of pipelineColourspace266 * @param colorspace pipeline colourspace e.g. rgb16, scrgb, lab, grey16 ...267 * @throws {Error} Invalid parameters268 * @returns A sharp instance that can be used to chain operations269 */270 pipelineColorspace(colorspace?: string): Sharp;271 272 /**273 * Set the output colourspace.274 * By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.275 * @param colourspace output colourspace e.g. srgb, rgb, cmyk, lab, b-w ...276 * @throws {Error} Invalid parameters277 * @returns A sharp instance that can be used to chain operations278 */279 toColourspace(colourspace?: string): Sharp;280 281 /**282 * Alternative spelling of toColourspace().283 * @param colorspace output colorspace e.g. srgb, rgb, cmyk, lab, b-w ...284 * @throws {Error} Invalid parameters285 * @returns A sharp instance that can be used to chain operations286 */287 toColorspace(colorspace: string): Sharp;288 289 //#endregion290 291 //#region Composite functions292 293 /**294 * Composite image(s) over the processed (resized, extracted etc.) image.295 *296 * The images to composite must be the same size or smaller than the processed image.297 * If both `top` and `left` options are provided, they take precedence over `gravity`.298 * @param images - Ordered list of images to composite299 * @throws {Error} Invalid parameters300 * @returns A sharp instance that can be used to chain operations301 */302 composite(images: OverlayOptions[]): Sharp;303 304 //#endregion305 306 //#region Input functions307 308 /**309 * Take a "snapshot" of the Sharp instance, returning a new instance.310 * Cloned instances inherit the input of their parent instance.311 * This allows multiple output Streams and therefore multiple processing pipelines to share a single input Stream.312 * @returns A sharp instance that can be used to chain operations313 */314 clone(): Sharp;315 316 /**317 * Fast access to (uncached) image metadata without decoding any compressed image data.318 * @returns A sharp instance that can be used to chain operations319 */320 metadata(callback: (err: Error, metadata: Metadata) => void): Sharp;321 322 /**323 * Fast access to (uncached) image metadata without decoding any compressed image data.324 * @returns A promise that resolves with a metadata object325 */326 metadata(): Promise<Metadata>;327 328 /**329 * Keep all metadata (EXIF, ICC, XMP, IPTC) from the input image in the output image.330 * @returns A sharp instance that can be used to chain operations331 */332 keepMetadata(): Sharp;333 334 /**335 * Access to pixel-derived image statistics for every channel in the image.336 * @returns A sharp instance that can be used to chain operations337 */338 stats(callback: (err: Error, stats: Stats) => void): Sharp;339 340 /**341 * Access to pixel-derived image statistics for every channel in the image.342 * @returns A promise that resolves with a stats object343 */344 stats(): Promise<Stats>;345 346 //#endregion347 348 //#region Operation functions349 350 /**351 * Rotate the output image by either an explicit angle352 * or auto-orient based on the EXIF `Orientation` tag.353 *354 * If an angle is provided, it is converted to a valid positive degree rotation.355 * For example, `-450` will produce a 270 degree rotation.356 *357 * When rotating by an angle other than a multiple of 90,358 * the background colour can be provided with the `background` option.359 *360 * If no angle is provided, it is determined from the EXIF data.361 * Mirroring is supported and may infer the use of a flip operation.362 *363 * The use of `rotate` without an angle will remove the EXIF `Orientation` tag, if any.364 *365 * Only one rotation can occur per pipeline (aside from an initial call without366 * arguments to orient via EXIF data). Previous calls to `rotate` in the same367 * pipeline will be ignored.368 *369 * Multi-page images can only be rotated by 180 degrees.370 *371 * Method order is important when rotating, resizing and/or extracting regions,372 * for example `.rotate(x).extract(y)` will produce a different result to `.extract(y).rotate(x)`.373 *374 * @example375 * const pipeline = sharp()376 * .rotate()377 * .resize(null, 200)378 * .toBuffer(function (err, outputBuffer, info) {379 * // outputBuffer contains 200px high JPEG image data,380 * // auto-rotated using EXIF Orientation tag381 * // info.width and info.height contain the dimensions of the resized image382 * });383 * readableStream.pipe(pipeline);384 *385 * @example386 * const rotateThenResize = await sharp(input)387 * .rotate(90)388 * .resize({ width: 16, height: 8, fit: 'fill' })389 * .toBuffer();390 * const resizeThenRotate = await sharp(input)391 * .resize({ width: 16, height: 8, fit: 'fill' })392 * .rotate(90)393 * .toBuffer();394 *395 * @param {number} [angle=auto] angle of rotation.396 * @param {Object} [options] - if present, is an Object with optional attributes.397 * @param {string|Object} [options.background="#000000"] parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.398 * @returns {Sharp}399 * @throws {Error} Invalid parameters400 */401 rotate(angle?: number, options?: RotateOptions): Sharp;402 403 /**404 * Alias for calling `rotate()` with no arguments, which orients the image based405 * on EXIF orientsion.406 *407 * This operation is aliased to emphasize its purpose, helping to remove any408 * confusion between rotation and orientation.409 *410 * @example411 * const output = await sharp(input).autoOrient().toBuffer();412 *413 * @returns {Sharp}414 */415 autoOrient(): Sharp416 417 /**418 * Flip the image about the vertical Y axis. This always occurs after rotation, if any.419 * The use of flip implies the removal of the EXIF Orientation tag, if any.420 * @param flip true to enable and false to disable (defaults to true)421 * @returns A sharp instance that can be used to chain operations422 */423 flip(flip?: boolean): Sharp;424 425 /**426 * Flop the image about the horizontal X axis. This always occurs after rotation, if any.427 * The use of flop implies the removal of the EXIF Orientation tag, if any.428 * @param flop true to enable and false to disable (defaults to true)429 * @returns A sharp instance that can be used to chain operations430 */431 flop(flop?: boolean): Sharp;432 433 /**434 * Perform an affine transform on an image. This operation will always occur after resizing, extraction and rotation, if any.435 * You must provide an array of length 4 or a 2x2 affine transformation matrix.436 * By default, new pixels are filled with a black background. You can provide a background colour with the `background` option.437 * A particular interpolator may also be specified. Set the `interpolator` option to an attribute of the `interpolators` Object e.g. `interpolators.nohalo`.438 *439 * In the case of a 2x2 matrix, the transform is:440 * X = matrix[0, 0] * (x + idx) + matrix[0, 1] * (y + idy) + odx441 * Y = matrix[1, 0] * (x + idx) + matrix[1, 1] * (y + idy) + ody442 *443 * where:444 *445 * x and y are the coordinates in input image.446 * X and Y are the coordinates in output image.447 * (0,0) is the upper left corner.448 *449 * @param matrix Affine transformation matrix, may either by a array of length four or a 2x2 matrix array450 * @param options if present, is an Object with optional attributes.451 *452 * @returns A sharp instance that can be used to chain operations453 */454 affine(matrix: [number, number, number, number] | Matrix2x2, options?: AffineOptions): Sharp;455 456 /**457 * Sharpen the image.458 * When used without parameters, performs a fast, mild sharpen of the output image.459 * When a sigma is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.460 * Fine-grained control over the level of sharpening in "flat" (m1) and "jagged" (m2) areas is available.461 * @param options if present, is an Object with optional attributes462 * @throws {Error} Invalid parameters463 * @returns A sharp instance that can be used to chain operations464 */465 sharpen(options?: SharpenOptions): Sharp;466 467 /**468 * Apply median filter. When used without parameters the default window is 3x3.469 * @param size square mask size: size x size (optional, default 3)470 * @throws {Error} Invalid parameters471 * @returns A sharp instance that can be used to chain operations472 */473 median(size?: number): Sharp;474 475 /**476 * Blur the image.477 * When used without parameters, performs a fast, mild blur of the output image.478 * When a sigma is provided, performs a slower, more accurate Gaussian blur.479 * When a boolean sigma is provided, ether blur mild or disable blur480 * @param sigma a value between 0.3 and 1000 representing the sigma of the Gaussian mask, where sigma = 1 + radius / 2.481 * @throws {Error} Invalid parameters482 * @returns A sharp instance that can be used to chain operations483 */484 blur(sigma?: number | boolean | BlurOptions): Sharp;485 486 /**487 * Expand foreground objects using the dilate morphological operator.488 * @param {Number} [width=1] dilation width in pixels.489 * @throws {Error} Invalid parameters490 * @returns A sharp instance that can be used to chain operations491 */492 dilate(width?: number): Sharp;493 494 /**495 * Shrink foreground objects using the erode morphological operator.496 * @param {Number} [width=1] erosion width in pixels.497 * @throws {Error} Invalid parameters498 * @returns A sharp instance that can be used to chain operations499 */500 erode(width?: number): Sharp;501 502 /**503 * Merge alpha transparency channel, if any, with background.504 * @param flatten true to enable and false to disable (defaults to true)505 * @returns A sharp instance that can be used to chain operations506 */507 flatten(flatten?: boolean | FlattenOptions): Sharp;508 509 /**510 * Ensure the image has an alpha channel with all white pixel values made fully transparent.511 * Existing alpha channel values for non-white pixels remain unchanged.512 * @returns A sharp instance that can be used to chain operations513 */514 unflatten(): Sharp;515 516 /**517 * Apply a gamma correction by reducing the encoding (darken) pre-resize at a factor of 1/gamma then increasing the encoding (brighten) post-resize at a factor of gamma.518 * This can improve the perceived brightness of a resized image in non-linear colour spaces.519 * JPEG and WebP input images will not take advantage of the shrink-on-load performance optimisation when applying a gamma correction.520 * Supply a second argument to use a different output gamma value, otherwise the first value is used in both cases.521 * @param gamma value between 1.0 and 3.0. (optional, default 2.2)522 * @param gammaOut value between 1.0 and 3.0. (optional, defaults to same as gamma)523 * @throws {Error} Invalid parameters524 * @returns A sharp instance that can be used to chain operations525 */526 gamma(gamma?: number, gammaOut?: number): Sharp;527 528 /**529 * Produce the "negative" of the image.530 * @param negate true to enable and false to disable, or an object of options (defaults to true)531 * @returns A sharp instance that can be used to chain operations532 */533 negate(negate?: boolean | NegateOptions): Sharp;534 535 /**536 * Enhance output image contrast by stretching its luminance to cover a full dynamic range.537 *538 * Uses a histogram-based approach, taking a default range of 1% to 99% to reduce sensitivity to noise at the extremes.539 *540 * Luminance values below the `lower` percentile will be underexposed by clipping to zero.541 * Luminance values above the `upper` percentile will be overexposed by clipping to the max pixel value.542 *543 * @param normalise options544 * @throws {Error} Invalid parameters545 * @returns A sharp instance that can be used to chain operations546 */547 normalise(normalise?: NormaliseOptions): Sharp;548 549 /**550 * Alternative spelling of normalise.551 * @param normalize options552 * @throws {Error} Invalid parameters553 * @returns A sharp instance that can be used to chain operations554 */555 normalize(normalize?: NormaliseOptions): Sharp;556 557 /**558 * Perform contrast limiting adaptive histogram equalization (CLAHE)559 *560 * This will, in general, enhance the clarity of the image by bringing out561 * darker details. Please read more about CLAHE here:562 * https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#Contrast_Limited_AHE563 *564 * @param options clahe options565 */566 clahe(options: ClaheOptions): Sharp;567 568 /**569 * Convolve the image with the specified kernel.570 * @param kernel the specified kernel571 * @throws {Error} Invalid parameters572 * @returns A sharp instance that can be used to chain operations573 */574 convolve(kernel: Kernel): Sharp;575 576 /**577 * Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0.578 * @param threshold a value in the range 0-255 representing the level at which the threshold will be applied. (optional, default 128)579 * @param options threshold options580 * @throws {Error} Invalid parameters581 * @returns A sharp instance that can be used to chain operations582 */583 threshold(threshold?: number, options?: ThresholdOptions): Sharp;584 585 /**586 * Perform a bitwise boolean operation with operand image.587 * This operation creates an output image where each pixel is the result of the selected bitwise boolean operation between the corresponding pixels of the input images.588 * @param operand Buffer containing image data or String containing the path to an image file.589 * @param operator one of "and", "or" or "eor" to perform that bitwise operation, like the C logic operators &, | and ^ respectively.590 * @param options describes operand when using raw pixel data.591 * @throws {Error} Invalid parameters592 * @returns A sharp instance that can be used to chain operations593 */594 boolean(operand: string | Buffer, operator: keyof BoolEnum, options?: { raw: Raw }): Sharp;595 596 /**597 * Apply the linear formula a * input + b to the image (levels adjustment)598 * @param a multiplier (optional, default 1.0)599 * @param b offset (optional, default 0.0)600 * @throws {Error} Invalid parameters601 * @returns A sharp instance that can be used to chain operations602 */603 linear(a?: number | number[] | null, b?: number | number[]): Sharp;604 605 /**606 * Recomb the image with the specified matrix.607 * @param inputMatrix 3x3 Recombination matrix or 4x4 Recombination matrix608 * @throws {Error} Invalid parameters609 * @returns A sharp instance that can be used to chain operations610 */611 recomb(inputMatrix: Matrix3x3 | Matrix4x4): Sharp;612 613 /**614 * Transforms the image using brightness, saturation, hue rotation and lightness.615 * Brightness and lightness both operate on luminance, with the difference being that brightness is multiplicative whereas lightness is additive.616 * @param options describes the modulation617 * @returns A sharp instance that can be used to chain operations618 */619 modulate(options?: {620 brightness?: number | undefined;621 saturation?: number | undefined;622 hue?: number | undefined;623 lightness?: number | undefined;624 }): Sharp;625 626 //#endregion627 628 //#region Output functions629 630 /**631 * Write output image data to a file.632 * If an explicit output format is not selected, it will be inferred from the extension, with JPEG, PNG, WebP, AVIF, TIFF, DZI, and libvips' V format supported.633 * Note that raw pixel data is only supported for buffer output.634 * @param fileOut The path to write the image data to.635 * @param callback Callback function called on completion with two arguments (err, info). info contains the output image format, size (bytes), width, height and channels.636 * @throws {Error} Invalid parameters637 * @returns A sharp instance that can be used to chain operations638 */639 toFile(fileOut: string, callback: (err: Error, info: OutputInfo) => void): Sharp;640 641 /**642 * Write output image data to a file.643 * @param fileOut The path to write the image data to.644 * @throws {Error} Invalid parameters645 * @returns A promise that fulfills with an object containing information on the resulting file646 */647 toFile(fileOut: string): Promise<OutputInfo>;648 649 /**650 * Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.651 * By default, the format will match the input image, except SVG input which becomes PNG output.652 * @param callback Callback function called on completion with three arguments (err, buffer, info).653 * @returns A sharp instance that can be used to chain operations654 */655 toBuffer(callback: (err: Error, buffer: Buffer<ArrayBuffer>, info: OutputInfo) => void): Sharp;656 657 /**658 * Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.659 * By default, the format will match the input image, except SVG input which becomes PNG output.660 * The underlying `ArrayBuffer` may be marked as non-transferable by some JavaScript runtimes.661 * @param options resolve options662 * @param options.resolveWithObject Resolve the Promise with an Object containing data and info properties instead of resolving only with data.663 * @returns A promise that resolves with the Buffer data.664 */665 toBuffer(options?: { resolveWithObject: false }): Promise<Buffer<ArrayBuffer>>;666 667 /**668 * Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.669 * By default, the format will match the input image, except SVG input which becomes PNG output.670 * The underlying `ArrayBuffer` may be marked as non-transferable by some JavaScript runtimes.671 * @param options resolve options672 * @param options.resolveWithObject Resolve the Promise with an Object containing data and info properties instead of resolving only with data.673 * @returns A promise that resolves with an object containing the Buffer data and an info object containing the output image format, size (bytes), width, height and channels674 */675 toBuffer(options: { resolveWithObject: true }): Promise<{ data: Buffer<ArrayBuffer>; info: OutputInfo }>;676 677 /**678 * Write output to a Uint8Array backed by a transferable ArrayBuffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.679 * By default, the format will match the input image, except SVG input which becomes PNG output.680 * @returns A promise that resolves with an object containing the Uint8Array data and an info object containing the output image format, size (bytes), width, height and channels681 */682 toUint8Array(): Promise<{ data: Uint8Array; info: OutputInfo }>;683 684 /**685 * Set output density (DPI) in EXIF metadata.686 * @param density Density in dots per inch (DPI).687 * @returns A sharp instance that can be used to chain operations688 * @throws {Error} Invalid parameters689 */690 withDensity(density: number): Sharp;691 692 /**693 * Keep all EXIF metadata from the input image in the output image.694 * EXIF metadata is unsupported for TIFF output.695 * @returns A sharp instance that can be used to chain operations696 */697 keepExif(): Sharp;698 699 /**700 * Set EXIF metadata in the output image, ignoring any EXIF in the input image.701 * @param {Exif} exif Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data.702 * @returns A sharp instance that can be used to chain operations703 * @throws {Error} Invalid parameters704 */705 withExif(exif: Exif): Sharp;706 707 /**708 * Update EXIF metadata from the input image in the output image.709 * @param {Exif} exif Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data.710 * @returns A sharp instance that can be used to chain operations711 * @throws {Error} Invalid parameters712 */713 withExifMerge(exif: Exif): Sharp;714 715 /**716 * Keep ICC profile from the input image in the output image where possible.717 * @returns A sharp instance that can be used to chain operations718 */719 keepIccProfile(): Sharp;720 721 /**722 * Transform using an ICC profile and attach to the output image.723 * @param {string} icc - Absolute filesystem path to output ICC profile or built-in profile name (srgb, p3, cmyk).724 * @returns A sharp instance that can be used to chain operations725 * @throws {Error} Invalid parameters726 */727 withIccProfile(icc: string, options?: WithIccProfileOptions): Sharp;728 729 /**730 * Keep all XMP metadata from the input image in the output image.731 * @returns A sharp instance that can be used to chain operations732 */733 keepXmp(): Sharp;734 735 /**736 * Set XMP metadata in the output image.737 * @param {string} xmp - String containing XMP metadata to be embedded in the output image.738 * @returns A sharp instance that can be used to chain operations739 * @throws {Error} Invalid parameters740 */741 withXmp(xmp: string): Sharp;742 743 /**744 * Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.745 * The default behaviour, when withMetadata is not used, is to strip all metadata and convert to the device-independent sRGB colour space.746 * This will also convert to and add a web-friendly sRGB ICC profile.747 * @param withMetadata748 * @throws {Error} Invalid parameters.749 */750 withMetadata(withMetadata?: WriteableMetadata): Sharp;751 752 /**753 * Use these JPEG options for output image.754 * @param options Output options.755 * @throws {Error} Invalid options756 * @returns A sharp instance that can be used to chain operations757 */758 jpeg(options?: JpegOptions): Sharp;759 760 /**761 * Use these JP2 (JPEG 2000) options for output image.762 * @param options Output options.763 * @throws {Error} Invalid options764 * @returns A sharp instance that can be used to chain operations765 */766 jp2(options?: Jp2Options): Sharp;767 768 /**769 * Use these JPEG-XL (JXL) options for output image.770 * This feature is experimental, please do not use in production systems.771 * Requires libvips compiled with support for libjxl.772 * The prebuilt binaries do not include this.773 * Image metadata (EXIF, XMP) is unsupported.774 * @param options Output options.775 * @throws {Error} Invalid options776 * @returns A sharp instance that can be used to chain operations777 */778 jxl(options?: JxlOptions): Sharp;779 780 /**781 * Use these PNG options for output image.782 * PNG output is always full colour at 8 or 16 bits per pixel.783 * Indexed PNG input at 1, 2 or 4 bits per pixel is converted to 8 bits per pixel.784 * @param options Output options.785 * @throws {Error} Invalid options786 * @returns A sharp instance that can be used to chain operations787 */788 png(options?: PngOptions): Sharp;789 790 /**791 * Use these WebP options for output image.792 * @param options Output options.793 * @throws {Error} Invalid options794 * @returns A sharp instance that can be used to chain operations795 */796 webp(options?: WebpOptions): Sharp;797 798 /**799 * Use these GIF options for output image.800 * Requires libvips compiled with support for ImageMagick or GraphicsMagick. The prebuilt binaries do not include this - see installing a custom libvips.801 * @param options Output options.802 * @throws {Error} Invalid options803 * @returns A sharp instance that can be used to chain operations804 */805 gif(options?: GifOptions): Sharp;806 807 /**808 * Use these AVIF options for output image.809 * @param options Output options.810 * @throws {Error} Invalid options811 * @returns A sharp instance that can be used to chain operations812 */813 avif(options?: AvifOptions): Sharp;814 815 /**816 * Use these HEIF options for output image.817 * Support for patent-encumbered HEIC images requires the use of a globally-installed libvips compiled with support for libheif, libde265 and x265.818 * @param options Output options.819 * @throws {Error} Invalid options820 * @returns A sharp instance that can be used to chain operations821 */822 heif(options?: HeifOptions): Sharp;823 824 /**825 * Use these TIFF options for output image.826 * @param options Output options.827 * @throws {Error} Invalid options828 * @returns A sharp instance that can be used to chain operations829 */830 tiff(options?: TiffOptions): Sharp;831 832 /**833 * Force output to be raw, uncompressed uint8 pixel data.834 * @param options Raw output options.835 * @throws {Error} Invalid options836 * @returns A sharp instance that can be used to chain operations837 */838 raw(options?: RawOptions): Sharp;839 840 /**841 * Force output to a given format.842 * @param format a String or an Object with an 'id' attribute843 * @param options output options844 * @throws {Error} Unsupported format or options845 * @returns A sharp instance that can be used to chain operations846 */847 toFormat(848 format: keyof FormatEnum | AvailableFormatInfo | "avif",849 options?:850 | OutputOptions851 | JpegOptions852 | PngOptions853 | WebpOptions854 | AvifOptions855 | HeifOptions856 | JxlOptions857 | GifOptions858 | Jp2Options859 | RawOptions860 | TiffOptions,861 ): Sharp;862 863 /**864 * Use tile-based deep zoom (image pyramid) output.865 * Set the format and options for tile images via the toFormat, jpeg, png or webp functions.866 * Use a .zip or .szi file extension with toFile to write to a compressed archive file format.867 * @param tile tile options868 * @throws {Error} Invalid options869 * @returns A sharp instance that can be used to chain operations870 */871 tile(tile?: TileOptions): Sharp;872 873 /**874 * Set a timeout for processing, in seconds. Use a value of zero to continue processing indefinitely, the default behaviour.875 * The clock starts when libvips opens an input image for processing. Time spent waiting for a libuv thread to become available is not included.876 * @param options Object with a `seconds` attribute between 0 and 3600 (number)877 * @throws {Error} Invalid options878 * @returns A sharp instance that can be used to chain operations879 */880 timeout(options: TimeoutOptions): Sharp;881 882 //#endregion883 884 //#region Resize functions885 886 /**887 * Resize image to width, height or width x height.888 *889 * When both a width and height are provided, the possible methods by which the image should fit these are:890 * - cover: Crop to cover both provided dimensions (the default).891 * - contain: Embed within both provided dimensions.892 * - fill: Ignore the aspect ratio of the input and stretch to both provided dimensions.893 * - inside: Preserving aspect ratio, resize the image to be as large as possible while ensuring its dimensions are less than or equal to both those specified.894 * - outside: Preserving aspect ratio, resize the image to be as small as possible while ensuring its dimensions are greater than or equal to both those specified.895 * Some of these values are based on the object-fit CSS property.896 *897 * When using a fit of cover or contain, the default position is centre. Other options are:898 * - position: top, right top, right, right bottom, bottom, left bottom, left, left top.899 * - gravity: north, northeast, east, southeast, south, southwest, west, northwest, center or centre.900 * - strategy: cover only, dynamically crop using either the entropy or attention strategy. Some of these values are based on the object-position CSS property.901 *902 * The strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,903 * discarding the edge with the lowest score based on the selected strategy.904 * - entropy: focus on the region with the highest Shannon entropy.905 * - attention: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.906 *907 * Possible interpolation kernels are:908 * - nearest: Use nearest neighbour interpolation.909 * - cubic: Use a Catmull-Rom spline.910 * - lanczos2: Use a Lanczos kernel with a=2.911 * - lanczos3: Use a Lanczos kernel with a=3 (the default).912 *913 * @param width pixels wide the resultant image should be. Use null or undefined to auto-scale the width to match the height.914 * @param height pixels high the resultant image should be. Use null or undefined to auto-scale the height to match the width.915 * @param options resize options916 * @throws {Error} Invalid parameters917 * @returns A sharp instance that can be used to chain operations918 */919 resize(widthOrOptions?: number | ResizeOptions | null, height?: number | null, options?: ResizeOptions): Sharp;920 921 /**922 * Shorthand for resize(null, null, options);923 *924 * @param options resize options925 * @throws {Error} Invalid parameters926 * @returns A sharp instance that can be used to chain operations927 */928 resize(options: ResizeOptions): Sharp;929 930 /**931 * Extend / pad / extrude one or more edges of the image with either932 * the provided background colour or pixels derived from the image.933 * This operation will always occur after resizing and extraction, if any.934 * @param extend single pixel count to add to all edges or an Object with per-edge counts935 * @throws {Error} Invalid parameters936 * @returns A sharp instance that can be used to chain operations937 */938 extend(extend: number | ExtendOptions): Sharp;939 940 /**941 * Extract a region of the image.942 * - Use extract() before resize() for pre-resize extraction.943 * - Use extract() after resize() for post-resize extraction.944 * - Use extract() before and after for both.945 *946 * @param region The region to extract947 * @throws {Error} Invalid parameters948 * @returns A sharp instance that can be used to chain operations949 */950 extract(region: Region): Sharp;951 952 /**953 * Trim pixels from all edges that contain values similar to the given background colour, which defaults to that of the top-left pixel.954 * Images with an alpha channel will use the combined bounding box of alpha and non-alpha channels.955 * The info response Object will contain trimOffsetLeft and trimOffsetTop properties.956 * @param options trim options957 * @throws {Error} Invalid parameters958 * @returns A sharp instance that can be used to chain operations959 */960 trim(options?: TrimOptions): Sharp;961 962 //#endregion963}964 965export type SharpInput = Buffer966 | ArrayBuffer967 | Uint8Array968 | Uint8ClampedArray969 | Int8Array970 | Uint16Array971 | Int16Array972 | Uint32Array973 | Int32Array974 | Float32Array975 | Float64Array976 | string;977 978export interface SharpOptions {979 /**980 * Auto-orient based on the EXIF `Orientation` tag, if present.981 * Mirroring is supported and may infer the use of a flip operation.982 *983 * Using this option will remove the EXIF `Orientation` tag, if any.984 */985 autoOrient?: boolean | undefined;986 /**987 * When to abort processing of invalid pixel data, one of (in order of sensitivity):988 * 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort.989 * Use the default 'warning' level with untrusted input. (optional, default 'warning')990 */991 failOn?: FailOnOptions | undefined;992 /**993 * Do not process input images where the number of pixels (width x height) exceeds this limit.994 * Assumes image dimensions contained in the input metadata can be trusted.995 * An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF). (optional, default 268402689)996 */997 limitInputPixels?: number | boolean | undefined;998 /**999 * Do not process input images where the number of channels exceeds this limit.1000 * Assumes image metadata can be trusted.1001 * An integral Number of channels, zero or false to remove limit, true to use default limit of 5. (optional, default 5)1002 */1003 limitInputChannels?: number | boolean | undefined;1004 /** Set this to true to remove safety features that help prevent memory exhaustion (SVG, PNG). (optional, default false) */1005 unlimited?: boolean | undefined;1006 /** Set this to false to use random access rather than sequential read. Some operations will do this automatically. */1007 sequentialRead?: boolean | undefined;1008 /** The DPI at which to render SVG and PDF images, in the range 1 to 100000. (optional, default 72) */1009 density?: number | undefined;1010 /** Should the embedded ICC profile, if any, be ignored. */1011 ignoreIcc?: boolean | undefined;1012 /** Number of pages to extract for multi-page input (GIF, TIFF, PDF), use -1 for all pages */1013 pages?: number | undefined;1014 /** Page number to start extracting from for multi-page input (GIF, TIFF, PDF), zero based. (optional, default 0) */1015 page?: number | undefined;1016 /** TIFF specific input options */1017 tiff?: TiffInputOptions | undefined;1018 /** SVG specific input options */1019 svg?: SvgInputOptions | undefined;1020 /** PDF specific input options */1021 pdf?: PdfInputOptions | undefined;1022 /** OpenSlide specific input options */1023 openSlide?: OpenSlideInputOptions | undefined;1024 /** JPEG 2000 specific input options */1025 jp2?: Jp2InputOptions | undefined;1026 /** @deprecated Use {@link SharpOptions.tiff} instead */1027 subifd?: number | undefined;1028 /** @deprecated Use {@link SharpOptions.pdf} instead */1029 pdfBackground?: ColorLike | undefined;1030 /** @deprecated Use {@link SharpOptions.openSlide} instead */1031 level?: number | undefined;1032 /** Set to `true` to read all frames/pages of an animated image (equivalent of setting `pages` to `-1`). (optional, default false) */1033 animated?: boolean | undefined;1034 /** Describes raw pixel input image data. See raw() for pixel ordering. */1035 raw?: CreateRaw | undefined;1036 /** Describes a new image to be created. */1037 create?: Create | undefined;1038 /** Describes a new text image to be created. */1039 text?: CreateText | undefined;1040 /** Describes how array of input images should be joined. */1041 join?: Join | undefined;1042}1043 1044export interface CacheOptions {1045 /** Is the maximum memory in MB to use for this cache (optional, default 50) */1046 memory?: number | undefined;1047 /** Is the maximum number of files to hold open (optional, default 20) */1048 files?: number | undefined;1049 /** Is the maximum number of operations to cache (optional, default 100) */1050 items?: number | undefined;1051}1052 1053export interface TimeoutOptions {1054 /** Number of seconds after which processing will be stopped (default 0, eg disabled) */1055 seconds: number;1056}1057 1058export interface SharpCounters {1059 /** The number of tasks this module has queued waiting for libuv to provide a worker thread from its pool. */1060 queue: number;1061 /** The number of resize tasks currently being processed. */1062 process: number;1063}1064 1065export interface Raw {1066 width: number;1067 height: number;1068 channels: Channels;1069}1070 1071export interface CreateRaw extends Raw {1072 /** Specifies that the raw input has already been premultiplied, set to true to avoid sharp premultiplying the image. (optional, default false) */1073 premultiplied?: boolean | undefined;1074 /** The height of each page/frame for animated images, must be an integral factor of the overall image height. */1075 pageHeight?: number | undefined;1076}1077 1078export type CreateChannels = 3 | 4;1079 1080export interface Create {1081 /** Number of pixels wide. */1082 width: number;1083 /** Number of pixels high. */1084 height: number;1085 /** Number of bands, 3 for RGB, 4 for RGBA */1086 channels: CreateChannels;1087 /** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */1088 background: ColorLike;1089 /** Describes a noise to be created. */1090 noise?: Noise | undefined;1091 /** The height of each page/frame for animated images, must be an integral factor of the overall image height. */1092 pageHeight?: number | undefined;1093 1094}1095 1096export interface CreateText {1097 /** Text to render as a UTF-8 string. It can contain Pango markup, for example `<i>Le</i>Monde`. */1098 text: string;1099 /** Font name to render with. */1100 font?: string;1101 /** Absolute filesystem path to a font file that can be used by `font`. */1102 fontfile?: string;1103 /** Integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries. (optional, default `0`) */1104 width?: number;1105 /**1106 * Integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution1107 * defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0. (optional, default `0`)1108 */1109 height?: number;1110 /** Text alignment ('left', 'centre', 'center', 'right'). (optional, default 'left') */1111 align?: TextAlign;1112 /** Set this to true to apply justification to the text. (optional, default `false`) */1113 justify?: boolean;1114 /** The resolution (size) at which to render the text. Does not take effect if `height` is specified. (optional, default `72`) */1115 dpi?: number;1116 /**1117 * Set this to true to enable RGBA output. This is useful for colour emoji rendering,1118 * or support for pango markup features like `<span foreground="red">Red!</span>`. (optional, default `false`)1119 */1120 rgba?: boolean;1121 /** Text line height in points. Will use the font line height if none is specified. (optional, default `0`) */1122 spacing?: number;1123 /** Word wrapping style when width is provided, one of: 'word', 'char', 'word-char' (prefer word, fallback to char) or 'none' */1124 wrap?: TextWrap;1125}1126 1127export interface Join {1128 /** Number of images per row. */1129 across?: number | undefined;1130 /** Treat input as frames of an animated image. */1131 animated?: boolean | undefined;1132 /** Space between images, in pixels. */1133 shim?: number | undefined;1134 /** Background colour. */1135 background?: ColorLike | undefined;1136 /** Horizontal alignment. */1137 halign?: HorizontalAlignment | undefined;1138 /** Vertical alignment. */1139 valign?: VerticalAlignment | undefined;1140}1141 1142export interface TiffInputOptions {1143 /** Sub Image File Directory to extract, defaults to main image. Use -1 for all subifds. */1144 subifd?: number | undefined;1145}1146 1147export interface SvgInputOptions {1148 /** Custom CSS for SVG input, applied with a User Origin during the CSS cascade. */1149 stylesheet?: string | undefined;1150 /** Set to `true` to render SVG input at 32-bits per channel (128-bit) instead of 8-bits per channel (32-bit) RGBA. */1151 highBitdepth?: boolean | undefined;1152}1153 1154export interface PdfInputOptions {1155 /** Background colour to use when PDF is partially transparent. Requires the use of a globally-installed libvips compiled with support for PDFium, Poppler, ImageMagick or GraphicsMagick. */1156 background?: ColorLike | undefined;1157}1158 1159export interface OpenSlideInputOptions {1160 /** Level to extract from a multi-level input, zero based. (optional, default 0) */1161 level?: number | undefined;1162}1163 1164export interface Jp2InputOptions {1165 /** Set to `true` to load JPEG 2000 images using [oneshot mode](https://github.com/libvips/libvips/issues/4205) */1166 oneshot?: boolean | undefined;1167}1168 1169export interface ExifDir {1170 [k: string]: string;1171}1172 1173export interface Exif {1174 'IFD0'?: ExifDir;1175 'IFD1'?: ExifDir;1176 'IFD2'?: ExifDir;1177 'IFD3'?: ExifDir;1178}1179 1180export type HeifCompression = 'av1' | 'hevc';1181 1182export type HeifTune = 'auto' | 'iq' | 'psnr' | 'ssim';1183 1184export type Unit = 'inch' | 'cm';1185 1186export type MediaType =1187 'application/pdf' |1188 'image/avif' |1189 'image/fits' |1190 'image/gif' |1191 'image/heic' |1192 'image/jp2' |1193 'image/jpeg' |1194 'image/jxl' |1195 'image/png' |1196 'image/svg+xml' |1197 'image/tiff' |1198 'image/vnd.radiance' |1199 'image/webp' |1200 'image/x-exr' |