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# sharp-ico2 3ICO encoder and decoder for [sharp](https://www.npmjs.com/package/sharp) base on [ico-endec](https://www.npmjs.com/package/ico-endec) (for encode) and [decode-ico](https://www.npmjs.com/package/decode-ico) (for decode).4 5## Install6 7```bash8npm install sharp-ico9```10 11## Usage12 13### Create instances of sharp from an ICO image14 15#### `ico.sharpsFromIco(input, options?, resolveWithObject?)`16 17- `input` (string | Buffer) - A String containing the filesystem path to an ICO image file, or a Buffer containing ICO image data.18- `options` Object (optional) - sharp constructor [options](https://sharp.pixelplumbing.com/api-constructor#parameters).19- `resolveWithObject` boolean (optional) - Return an array of Object containing `image` (instance of sharp) property and [decoding info](#decodinginfo) instead of only instance of sharp. Default by `false`.20 21Returns `Sharp[] | ImageData[]` - Return an array of instance of sharp or Object containing `image` (instance of sharp) property and [decoding info](#decodinginfo).22 23```js24const ico = require("sharp-ico");25 26ico27 .sharpsFromIco("input.ico", {28 // sharp constructor options29 }) // returns an array of instance of sharp30 .forEach(async (icon, index) => {31 icon.toFile(`output-${index}.png`);32 33 // Or34 const metadata = await icon.metadata();35 icon.toFile(`output-${metadata.width}x${metadata.height}.png`);36 });37 38// Set the third option to `true`, will return objects with decoding info39ico40 .sharpsFromIco("input.ico", null, true)41 .forEach((icon) => {42 icon.image.toFile(`output-${icon.width}x${icon.height}.png`);43 });44```45 46### Write an ICO file47 48#### `ico.sharpsToIco(icons, fileOut, options?)`49 50- `icons` Sharp[] - An array of instance of sharp.51- `fileOut` string - The path to write the image data to.52- `options` Object (optional)53 - `sizes` (number[] | `"default"`) - Array of sizes to use when resizing. `"default"` equal to `[256, 128, 64, 48, 32, 24, 16]`.54 - `resizeOptions` Object (optional) - sharp resize [options](https://sharp.pixelplumbing.com/api-resize#parameters).55 56Returns `Promise<Object>` - Resolve with an Object containing `size`, `width`, `height` properties.57 58```js59const sharp = require("sharp");60const ico= require("sharp-ico");61const bmp = require("sharp-bmp"); // if need to write bmp icons62 63ico64 .sharpsToIco(65 [66 sharp("input-256x256.png"),67 bmp.sharpFromBmp("input-64x64.bmp"),68 sharp("input-32x32.png"),69 // more sizes...70 ],71 "output.ico"72 )73 .then((info) => {74 console.log(info); // { size, width, height }75 })76 .catch((err) => {77 console.error(err);78 });79 80// sizes options81ico82 .sharpsToIco(83 [84 sharp("input-256x256.png")85 ],86 "output.ico",87 {88 sizes: [64, 32, 24],89 // sizes: "default", // equal to [256, 128, 64, 48, 32, 24, 16]90 resizeOptions: {}, // sharp resize optinos91 }92 ); // will output a 64x64 ico image (with 32x32 and 24x24 sizes)93```94 95### Decode ICO96 97#### `ico.decode(buffer)`98 99- `buffer` Buffer - A Buffer containing ICO image data.100 101Returns `Object[]` - Return an array of Object contains the following <span id="decodinginfo">decoding info</span>:102 103- `width` number - The width of the image, in pixels.104- `height` number - The height of the image, in pixels.105- `type` string - The type of image, will be one of `bmp` or `png`.106- `data` Uint8Array - The data of the image, format depends on type, see below.107- `bpp` number - The color depth of the image as the number of bits used per pixel.108- `hotspot` null | { x: number, y: number } - If the image is a cursor (.cur), this is the hotspot.109 110The format of the `data` parameter depends on the `type` of image. When the image is of type `bmp`, the data array will hold raw pixel data in the RGBA order, with integer values between 0 and 255 (included). When the type is `png`, the array will be png data.111 112```js113const fs = require("fs");114const sharp = require("sharp");115const ico = require("sharp-ico");116 117const buffer = fs.readFileSync("input.ico");118const icons = ico.decode(buffer);119 120icons.forEach((icon) => {121 const image = icon.type === "png"122 ? sharp(icon.data)123 : sharp(icon.data, {124 raw: {125 width: icon.width,126 height: icon.height,127 channels: 4,128 },129 });130 image.toFile(`output-${icon.width}x${icon.height}.png`);131});132```133 134### Encode ICO135 136#### `ico.encode(bufferList)`137 138- `bufferList` Buffer[] - An array of Buffer containing PNG or BMP image data.139 140Returns `Buffer` - Return a buffer containing ICO image data.141 142```js143const fs = require("fs");144const sharp = require("sharp");145const ico = require("sharp-ico");146const bmp = require("sharp-bmp"); // if need to write bmp icons147 148(async () => {149 const icons = [150 sharp("input-256x256.png"),151 bmp.sharpFromBmp("input-64x64.bmp"),152 sharp("input-32x32.png"),153 ];154 const bufferList = [];155 for (let i = 0; i < icons.length; i++) {156 const buffer = await icons[i].toFormat("png").toBuffer();157 bufferList.push(buffer);158 }159 const icoBuffer = ico.encode(bufferList);160 fs.writeFileSync("output.ico", icoBuffer);161 162 console.log(icoBuffer.length); // size of output.ico163})();164```165 166## Change Log167 168### 0.1.1169 170- `sharpsToIco` support `sizes` option171 172### 0.1.5173 174- Use [decode-ico](https://www.npmjs.com/package/decode-ico) instead of [ico-endec](https://www.npmjs.com/package/ico-endec) for decoding to support transparent bmp icons.175 176 177 