Download node_modules/@jimp/tiff/src/index.js from sweet2004/bot: direct link, hf CLI and curl.
- Browser
- Download file 710 Bytes
-
https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40jimp/tiff/src/index.js
- Command line
-
hf download hf://spaces/sweet2004/bot/node_modules/@jimp/tiff/src/index.js
-
curl -L -o index.js https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40jimp/tiff/src/index.js
710 Bytes
| import UTIF from "utif"; | |
| const MIME_TYPE = "image/tiff"; | |
| export default () => ({ | |
| mime: { [MIME_TYPE]: ["tiff", "tif"] }, | |
| constants: { | |
| MIME_TIFF: MIME_TYPE, | |
| }, | |
| decoders: { | |
| [MIME_TYPE]: (data) => { | |
| const ifds = UTIF.decode(data); | |
| const page = ifds[0]; | |
| UTIF.decodeImages(data, ifds); | |
| const rgba = UTIF.toRGBA8(page); | |
| return { | |
| data: Buffer.from(rgba), | |
| width: page.t256[0], | |
| height: page.t257[0], | |
| }; | |
| }, | |
| }, | |
| encoders: { | |
| [MIME_TYPE]: (image) => { | |
| const tiff = UTIF.encodeImage( | |
| image.bitmap.data, | |
| image.bitmap.width, | |
| image.bitmap.height | |
| ); | |
| return Buffer.from(tiff); | |
| }, | |
| }, | |
| }); | |