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.
03k
1/*!2 Copyright 2013 Lovell Fuller and others.3 SPDX-License-Identifier: Apache-2.04*/5 6import util from 'node:util';7import stream from 'node:stream';8import is from './is.mjs';9 10import './sharp.mjs';11 12// Use NODE_DEBUG=sharp to enable libvips warnings13const debuglog = util.debuglog('sharp');14 15const queueListener = (queueLength) => {16 Sharp.queue.emit('change', queueLength);17};18 19/**20 * Constructor factory to create an instance of `sharp`, to which further methods are chained.21 *22 * JPEG, PNG, WebP, GIF, AVIF or TIFF format image data can be streamed out from this object.23 * When using Stream based output, derived attributes are available from the `info` event.24 *25 * Non-critical problems encountered during processing are emitted as `warning` events.26 *27 * Implements the [stream.Duplex](http://nodejs.org/api/stream.html#stream_class_stream_duplex) class.28 *29 * When loading more than one page/frame of an animated image,30 * these are combined as a vertically-stacked "toilet roll" image31 * where the overall height is the `pageHeight` multiplied by the number of `pages`.32 *33 * @constructs Sharp34 *35 * @emits Sharp#info36 * @emits Sharp#warning37 *38 * @example39 * sharp('input.jpg')40 * .resize(300, 200)41 * .toFile('output.jpg', function(err) {42 * // output.jpg is a 300 pixels wide and 200 pixels high image43 * // containing a scaled and cropped version of input.jpg44 * });45 *46 * @example47 * // Read image data from remote URL,48 * // resize to 300 pixels wide,49 * // emit an 'info' event with calculated dimensions50 * // and finally write image data to writableStream51 * const { body } = await fetch('https://...');52 * const readableStream = Readable.fromWeb(body);53 * const transformer = sharp()54 * .resize(300)55 * .on('info', ({ height }) => {56 * console.log(`Image height is ${height}`);57 * });58 * readableStream.pipe(transformer).pipe(writableStream);59 *60 * @example61 * // Web Streams API, requires Node.js >= 24.15.062 * import { Duplex } from 'node:stream';63 *64 * const { body } = await fetch('https://...');65 * const transformer = Duplex.toWeb(66 * sharp().resize(300),67 * { readableType: 'bytes' }68 * );69 * body.pipeThrough(transformer).pipeTo(writable);70 *71 * @example72 * // Create a blank 300x200 PNG image of semi-translucent red pixels73 * sharp({74 * create: {75 * width: 300,76 * height: 200,77 * channels: 4,78 * background: { r: 255, g: 0, b: 0, alpha: 0.5 }79 * }80 * })81 * .png()82 * .toBuffer()83 * .then( ... );84 *85 * @example86 * // Convert an animated GIF to an animated WebP87 * await sharp('in.gif', { animated: true }).toFile('out.webp');88 *89 * @example90 * // Read a raw array of pixels and save it to a png91 * const input = Uint8Array.from([255, 255, 255, 0, 0, 0]); // or Uint8ClampedArray92 * const image = sharp(input, {93 * // because the input does not contain its dimensions or how many channels it has94 * // we need to specify it in the constructor options95 * raw: {96 * width: 2,97 * height: 1,98 * channels: 399 * }100 * });101 * await image.toFile('my-two-pixels.png');102 *103 * @example104 * // Generate RGB Gaussian noise105 * await sharp({106 * create: {107 * width: 300,108 * height: 200,109 * channels: 3,110 * noise: {111 * type: 'gaussian',112 * mean: 128,113 * sigma: 30114 * }115 * }116 * }).toFile('noise.png');117 *118 * @example119 * // Generate an image from text120 * await sharp({121 * text: {122 * text: 'Hello, world!',123 * width: 400, // max width124 * height: 300 // max height125 * }126 * }).toFile('text_bw.png');127 *128 * @example129 * // Generate an rgba image from text using pango markup and font130 * await sharp({131 * text: {132 * text: '<span foreground="red">Red!</span><span background="cyan">blue</span>',133 * font: 'sans',134 * rgba: true,135 * dpi: 300136 * }137 * }).toFile('text_rgba.png');138 *139 * @example140 * // Join four input images as a 2x2 grid with a 4 pixel gutter141 * const data = await sharp(142 * [image1, image2, image3, image4],143 * { join: { across: 2, shim: 4 } }144 * ).toBuffer();145 *146 * @example147 * // Generate a two-frame animated image from emoji148 * const images = ['😀', '😛'].map(text => ({149 * text: { text, width: 64, height: 64, channels: 4, rgba: true }150 * }));151 * await sharp(images, { join: { animated: true } }).toFile('out.gif');152 *153 * @param {(Buffer|ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array|Float32Array|Float64Array|string|Array)} [input] - if present, can be154 * a Buffer / ArrayBuffer / Uint8Array / Uint8ClampedArray containing JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image data, or155 * a TypedArray containing raw pixel image data, or156 * a String containing the filesystem path to an JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image file.157 * An array of inputs can be provided, and these will be joined together.158 * JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.159 * @param {Object} [options] - if present, is an Object with optional attributes.160 * @param {string} [options.failOn='warning'] - When to abort processing of invalid pixel data, one of (in order of sensitivity, least to most): 'none', 'truncated', 'error', 'warning'. Higher levels imply lower levels. Invalid metadata will always abort. Use the default 'warning' level with untrusted input.161 * @param {number|boolean} [options.limitInputPixels=268402689] - Do not process input images where the number of pixels162 * (width x height) exceeds this limit. Assumes image dimensions contained in the input metadata can be trusted.163 * An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF).164 * @param {number|boolean} [options.limitInputChannels=5] - Do not process input images where the number of channels exceeds this limit. Assumes image metadata can be trusted.165 * An integral Number of channels, zero or false to remove limit, true to use default limit of 5.166 * @param {boolean} [options.unlimited=false] - Set this to `true` to remove safety features that help prevent memory exhaustion (JPEG, PNG, SVG, HEIF).167 * @param {boolean} [options.autoOrient=false] - Set this to `true` to rotate/flip the image to match EXIF `Orientation`, if any.168 * @param {boolean} [options.sequentialRead=true] - Set this to `false` to use random access rather than sequential read. Some operations will do this automatically.169 * @param {number} [options.density=72] - The DPI at which to render SVG and PDF images, in the range 1 to 100000.170 * @param {number} [options.ignoreIcc=false] - should the embedded ICC profile, if any, be ignored.171 * @param {number} [options.pages=1] - Number of pages to extract for multi-page input (GIF, WebP, TIFF), use -1 for all pages.172 * @param {number} [options.page=0] - Page number to start extracting from for multi-page input (GIF, WebP, TIFF), zero based.173 * @param {boolean} [options.animated=false] - Set to `true` to read all frames/pages of an animated image (GIF, WebP, TIFF), equivalent of setting `pages` to `-1`.174 * @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.175 * @param {number} [options.raw.width] - integral number of pixels wide.176 * @param {number} [options.raw.height] - integral number of pixels high.177 * @param {number} [options.raw.channels] - integral number of channels, between 1 and 4.178 * @param {boolean} [options.raw.premultiplied] - specifies that the raw input has already been premultiplied, set to `true`179 * to avoid sharp premultiplying the image. (optional, default `false`)180 * @param {number} [options.raw.pageHeight] - The pixel height of each page/frame for animated images, must be an integral factor of `raw.height`.181 * @param {Object} [options.create] - describes a new image to be created.182 * @param {number} [options.create.width] - integral number of pixels wide.183 * @param {number} [options.create.height] - integral number of pixels high.184 * @param {number} [options.create.channels] - integral number of channels, either 3 (RGB) or 4 (RGBA).185 * @param {string|Object} [options.create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.186 * @param {number} [options.create.pageHeight] - The pixel height of each page/frame for animated images, must be an integral factor of `create.height`.187 * @param {Object} [options.create.noise] - describes a noise to be created.188 * @param {string} [options.create.noise.type] - type of generated noise, currently only `gaussian` is supported.189 * @param {number} [options.create.noise.mean=128] - Mean value of pixels in the generated noise.190 * @param {number} [options.create.noise.sigma=30] - Standard deviation of pixel values in the generated noise.191 * @param {Object} [options.text] - describes a new text image to be created.192 * @param {string} [options.text.text] - text to render as a UTF-8 string. It can contain Pango markup, for example `<i>Le</i>Monde`.193 * @param {string} [options.text.font] - font name to render with.194 * @param {string} [options.text.fontfile] - absolute filesystem path to a font file that can be used by `font`.195 * @param {number} [options.text.width=0] - Integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries.196 * @param {number} [options.text.height=0] - Maximum integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0.197 * @param {string} [options.text.align='left'] - Alignment style for multi-line text (`'left'`, `'centre'`, `'center'`, `'right'`).198 * @param {boolean} [options.text.justify=false] - set this to true to apply justification to the text.199 * @param {number} [options.text.dpi=72] - the resolution (size) at which to render the text. Does not take effect if `height` is specified.200 * @param {boolean} [options.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for pango markup features like `<span foreground="red">Red!</span>`.201 * @param {number} [options.text.spacing=0] - text line height in points. Will use the font line height if none is specified.202 * @param {string} [options.text.wrap='word'] - word wrapping style when width is provided, one of: 'word', 'char', 'word-char' (prefer word, fallback to char) or 'none'.203 * @param {Object} [options.join] - describes how an array of input images should be joined.204 * @param {number} [options.join.across=1] - number of images to join horizontally.205 * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image.206 * @param {number} [options.join.shim=0] - number of pixels to insert between joined images.207 * @param {string|Object} [options.join.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.208 * @param {string} [options.join.halign='left'] - horizontal alignment style for images joined horizontally (`'left'`, `'centre'`, `'center'`, `'right'`).209 * @param {string} [options.join.valign='top'] - vertical alignment style for images joined vertically (`'top'`, `'centre'`, `'center'`, `'bottom'`).210 * @param {Object} [options.tiff] - Describes TIFF specific options.211 * @param {number} [options.tiff.subifd=-1] - Sub Image File Directory to extract for OME-TIFF, defaults to main image.212 * @param {Object} [options.svg] - Describes SVG specific options.213 * @param {string} [options.svg.stylesheet] - Custom CSS for SVG input, applied with a User Origin during the CSS cascade.214 * @param {boolean} [options.svg.highBitdepth=false] - Set to `true` to render SVG input at 32-bits per channel (128-bit) instead of 8-bits per channel (32-bit) RGBA.215 * @param {Object} [options.pdf] - Describes PDF specific options. Requires the use of a globally-installed libvips compiled with support for PDFium, Poppler, ImageMagick or GraphicsMagick.216 * @param {string|Object} [options.pdf.background] - Background colour to use when PDF is partially transparent. Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.217 * @param {Object} [options.openSlide] - Describes OpenSlide specific options. Requires the use of a globally-installed libvips compiled with support for OpenSlide.218 * @param {number} [options.openSlide.level=0] - Level to extract from a multi-level input, zero based.219 * @param {Object} [options.jp2] - Describes JPEG 2000 specific options. Requires the use of a globally-installed libvips compiled with support for OpenJPEG.220 * @param {boolean} [options.jp2.oneshot=false] - Set to `true` to decode tiled JPEG 2000 images in a single operation, improving compatibility.221 * @returns {Sharp}222 * @throws {Error} Invalid parameters223 */224const Sharp = function (input, options) {225 // biome-ignore lint/complexity/noArguments: constructor factory226 if (arguments.length === 1 && !is.defined(input)) {227 throw new Error('Invalid input');228 }229 if (!(this instanceof Sharp)) {230 return new Sharp(input, options);231 }232 stream.Duplex.call(this);233 this.options = {234 // resize options235 topOffsetPre: -1,236 leftOffsetPre: -1,237 widthPre: -1,238 heightPre: -1,239 topOffsetPost: -1,240 leftOffsetPost: -1,241 widthPost: -1,242 heightPost: -1,243 width: -1,244 height: -1,245 canvas: 'crop',246 position: 0,247 resizeBackground: [0, 0, 0, 255],248 angle: 0,249 rotationAngle: 0,250 rotationBackground: [0, 0, 0, 255],251 rotateBefore: false,252 orientBefore: false,253 flip: false,254 flop: false,255 extendTop: 0,256 extendBottom: 0,257 extendLeft: 0,258 extendRight: 0,259 extendBackground: [0, 0, 0, 255],260 extendWith: 'background',261 withoutEnlargement: false,262 withoutReduction: false,263 affineMatrix: [],264 affineBackground: [0, 0, 0, 255],265 affineIdx: 0,266 affineIdy: 0,267 affineOdx: 0,268 affineOdy: 0,269 affineInterpolator: this.constructor.interpolators.bilinear,270 kernel: 'lanczos3',271 fastShrinkOnLoad: true,272 // operations273 tint: [-1, 0, 0, 0],274 flatten: false,275 flattenBackground: [0, 0, 0],276 unflatten: false,277 negate: false,278 negateAlpha: true,279 medianSize: 0,280 blurSigma: 0,281 precision: 'integer',282 minAmpl: 0.2,283 sharpenSigma: 0,284 sharpenM1: 1,285 sharpenM2: 2,286 sharpenX1: 2,287 sharpenY2: 10,288 sharpenY3: 20,289 threshold: 0,290 thresholdGrayscale: true,291 trimBackground: [],292 trimThreshold: -1,293 trimLineArt: false,294 trimMargin: 0,295 dilateWidth: 0,296 erodeWidth: 0,297 gamma: 0,298 gammaOut: 0,299 greyscale: false,300 normalise: false,301 normaliseLower: 1,302 normaliseUpper: 99,303 claheWidth: 0,304 claheHeight: 0,305 claheMaxSlope: 3,306 brightness: 1,307 saturation: 1,308 hue: 0,309 lightness: 0,310 booleanBufferIn: null,311 booleanFileIn: '',312 joinChannelIn: [],313 extractChannel: -1,314 removeAlpha: false,315 ensureAlpha: -1,316 colourspace: 'srgb',317 colourspacePipeline: 'last',318 composite: [],319 // output320 fileOut: '',321 formatOut: 'input',322 streamOut: false,323 typedArrayOut: false,324 keepMetadata: 0,325 withMetadataOrientation: -1,326 withMetadataDensity: 0,327 withIccProfile: '',328 withExif: {},329 withExifMerge: true,330 withXmp: '',331 keepGainMap: false,332 withGainMap: false,333 resolveWithObject: false,334 loop: -1,335 delay: [],336 // output format337 jpegQuality: 80,338 jpegProgressive: false,339 jpegChromaSubsampling: '4:2:0',340 jpegTrellisQuantisation: false,341 jpegOvershootDeringing: false,342 jpegOptimiseScans: false,343 jpegOptimiseCoding: true,344 jpegQuantisationTable: 0,345 pngProgressive: false,346 pngCompressionLevel: 6,347 pngAdaptiveFiltering: false,348 pngPalette: false,349 pngQuality: 100,350 pngEffort: 7,351 pngBitdepth: 8,352 pngDither: 1,353 jp2Quality: 80,354 jp2TileHeight: 512,355 jp2TileWidth: 512,356 jp2Lossless: false,357 jp2ChromaSubsampling: '4:4:4',358 webpQuality: 80,359 webpAlphaQuality: 100,360 webpLossless: false,361 webpNearLossless: false,362 webpSmartSubsample: false,363 webpSmartDeblock: false,364 webpPreset: 'default',365 webpEffort: 4,366 webpMinSize: false,367 webpMixed: false,368 webpExact: false,369 gifBitdepth: 8,370 gifEffort: 7,371 gifDither: 1,372 gifInterFrameMaxError: 0,373 gifInterPaletteMaxError: 3,374 gifKeepDuplicateFrames: false,375 gifReuse: true,376 gifProgressive: false,377 tiffQuality: 80,378 tiffCompression: 'jpeg',379 tiffBigtiff: false,380 tiffPredictor: 'horizontal',381 tiffPyramid: false,382 tiffMiniswhite: false,383 tiffBitdepth: 0,384 tiffTile: false,385 tiffTileHeight: 256,386 tiffTileWidth: 256,387 tiffXres: 1.0,388 tiffYres: 1.0,389 tiffResolutionUnit: 'inch',390 heifQuality: 50,391 heifLossless: false,392 heifCompression: 'av1',393 heifEffort: 4,394 heifChromaSubsampling: '4:4:4',395 heifBitdepth: 8,396 heifTune: 'auto',397 jxlDistance: 1,398 jxlDecodingTier: 0,399 jxlEffort: 7,400 jxlLossless: false,401 rawDepth: 'uchar',402 tileSize: 256,403 tileOverlap: 0,404 tileContainer: 'fs',405 tileLayout: 'dz',406 tileFormat: 'last',407 tileDepth: 'last',408 tileAngle: 0,409 tileSkipBlanks: -1,410 tileBackground: [255, 255, 255, 255],411 tileCentre: false,412 tileId: 'https://example.com/iiif',413 tileBasename: '',414 timeoutSeconds: 0,415 linearA: [],416 linearB: [],417 pdfBackground: [255, 255, 255, 255],418 // Function to notify of libvips warnings419 debuglog: warning => {420 this.emit('warning', warning);421 debuglog(warning);422 },423 // Function to notify of queue length changes424 queueListener425 };426 this.options.input = this._createInputDescriptor(input, options, { allowStream: true });427 return this;428};429Object.setPrototypeOf(Sharp.prototype, stream.Duplex.prototype);430Object.setPrototypeOf(Sharp, stream.Duplex);431 432/**433 * Take a "snapshot" of the Sharp instance, returning a new instance.434 * Cloned instances inherit the input of their parent instance.435 * This allows multiple output Streams and therefore multiple processing pipelines to share a single input Stream.436 *437 * @example438 * // firstWritableStream receives auto-rotated, resized readableStream439 * // secondWritableStream receives auto-rotated, extracted region of readableStream440 *441 * const pipeline = sharp().rotate();442 * pipeline443 * .clone()444 * .resize(800, 600)445 * .pipe(firstWritableStream);446 * pipeline447 * .clone()448 * .extract({ left: 20, top: 20, width: 100, height: 100 })449 * .pipe(secondWritableStream);450 * readableStream.pipe(pipeline);451 *452 * @example453 * // Create a pipeline that will download an image, resize it and format it to different files454 * // Using Promises to know when the pipeline is complete455 *456 * const sharpStream = sharp();457 *458 * const promises = [];459 * promises.push(460 * sharpStream461 * .clone()462 * .jpeg({ quality: 100 })463 * .toFile("originalFile.jpg")464 * );465 * promises.push(466 * sharpStream467 * .clone()468 * .resize({ width: 500 })469 * .jpeg({ quality: 80 })470 * .toFile("optimized-500.jpg")471 * );472 * promises.push(473 * sharpStream474 * .clone()475 * .resize({ width: 500 })476 * .webp({ quality: 80 })477 * .toFile("optimized-500.webp")478 * );479 *480 * const res = await fetch("https://www.example.com/some-file.jpg")481 * Readable.fromWeb(res.body).pipe(sharpStream);482 * await Promise.all(promises);483 *484 * @returns {Sharp}485 */486function clone () {487 // Clone existing options488 const clone = this.constructor.call();489 const { debuglog, queueListener, ...options } = this.options;490 clone.options = structuredClone(options);491 clone.options.debuglog = debuglog;492 clone.options.queueListener = queueListener;493 // Pass 'finish' event to clone for Stream-based input494 if (this._isStreamInput()) {495 this.on('finish', () => {496 // Clone inherits input data497 this._flattenBufferIn();498 clone.options.input.buffer = this.options.input.buffer;499 clone.emit('finish');500 });501 }502 return clone;503}504Object.assign(Sharp.prototype, { clone });505 506/**507 * Export constructor.508 * @module Sharp509 * @private510 */511export default Sharp;512 