{"name":"utif","description":"Fast and advanced TIFF decoder","version":"2.0.1","homepage":"https://github.com/photopea/UTIF.js","author":{"name":"photopea","url":"https://github.com/photopea"},"contributors":[{"name":"Scimonster","url":"https://github.com/Scimonster"}],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/photopea/UTIF.js.git"},"bugs":{"url":"https://github.com/photopea/UTIF.js/issues"},"main":"UTIF","keywords":["tiff","image","conversion"],"dependencies":{"pako":"^1.0.5"},"gitHead":"1ba12779ddfdfa50b0593cffec056a19c98c0f6f","_id":"utif@2.0.1","_npmVersion":"6.2.0","_nodeVersion":"10.8.0","_npmUser":{"name":"alisowski","email":"lisowski54@gmail.com"},"dist":{"integrity":"sha512-Z/S1fNKCicQTf375lIP9G8Sa1H/phcysstNrrSdZKj1f9g58J4NMgb5IgiEZN9/nLMPDwF0W7hdOe9Qq2IYoLg==","shasum":"9e1582d9bbd20011a6588548ed3266298e711759","tarball":"http://registry-npm.ywwl.com/utif/download/utif-2.0.1.tgz","fileCount":4,"unpackedSize":57104,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbiv6mCRA9TVsSAnZWagAAttsP/jyaPgXlnApzHRNo5Py9\nXLfCUSlxoxu0p8LVs/qzRHw9jH3z/jd65CFwDh28elV1GDWWVBKox9KRQJzF\nCpZXVCTPVLLkJrb9JoiGztO1go2hcZBFOPeYJ2Eys/gYDIK4nGQeThFnUaf7\n99ahZIgWFOXPy/ODfGcrZwhsrBg63gZ896KJ5MAJ73vpHuuS7gsYMc9Q9mq7\nJBuqw+s3SzC6EbeQmAiVocrjKM7n+oVoRe2N6/9rJaxqi+C1MhZqFMaN7pDY\nvfYgLOHf1xUw2tH3ipCvqtZQ4fKQQINJfKgWNA/ep7CtxfC4QTqaC63mnPzU\nDpq2DJ0Jzo9/f30upY9Dnto7XKldtEJ3ckfDsE5dYjdKkP3ifql3jvgBv623\nrYH3493eAK2RBwhh4UfB+LyHTVWufySdt1hfbSIDGQcx6tY3tfexhG8cL74X\n44L2S8KhbjT0casyj/kZyETCruZxxHTngY6c6IgASBButVv51RX8vBb2xS59\nMUP/6eAKMXEZQRP+pzDMCw51216oIuYgRcQF2heuj6WW89My4pmWBIsX9tWC\ntECsULo8woJZzD6+emhOhtemIXt0YWEtf70Bh0A+Qv9z9EvFtnlKCUUOXfca\n7Rxiy1VQ+POj6lzbV4cQu/BiojB+Em7uvXLUBRnVtxo6jC/swJsja4nqaAz3\nOlZT\r\n=zjrH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGgmiJS1Oc5RVzjr1LLRfUVO8MiYAHIBQzGSoUFy482KAiAxiXABDW5Rroi6Ojf4Rr/3VuxM9RDe+VS6+0ZACRLVBg=="}],"size":20040,"noattachment":false,"key":"/utif/-/utif-2.0.1.tgz"},"maintainers":[{"name":"photopea","email":"support@photopea.com"},{"name":"scimonster","email":"tehalmightyscimonster@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utif_2.0.1_1535835813184_0.735027429987511"},"_hasShrinkwrap":false,"readme":"# UTIF.js\nA small, fast and advanced TIFF / EXIF (+ DNG, CR2, NEF and other TIFF-ish files) decoder and encoder. It is the main TIFF library for [Photopea image editor](https://www.photopea.com). Try to open your TIFF file with Photopea to see, if UTIF.js can parse it.\n\n* Supports Black & White, Grayscale, RGB and Paletted images\n* Supports Fax 3 and Fax 4 (CCITT), JPEG, LZW, PackBits and other compressions (1,3,4,5,6,7,8,32773,32809)\n* E.g. [this 8 MPix image](//www.photopea.com/api/img/G4.TIF) with Fax 4 compression is just 56 kB ( [Open in Photopea](https://www.photopea.com?p=%7B%22files%22:%5B%22//www.photopea.com/api/img/G4.TIF%22%5D%7D) )\n\nFor RAW files, UTIF.js only decodes raw sensor data (and JPG previews, if there are any). It does not convert the raw data into a displayable image (RGBA). Such conversion is complex and out of scope of this library.\n\n## Installation\n\nDownload and include the `UTIF.js` file in your code. If you're in NodeJS or otherwise using NPM, run:\n\n```sh\nnpm install utif\n```\n\n#### `UTIF.decode(buffer)`\n* `buffer`: ArrayBuffer containing TIFF or EXIF data\n* returns an array of \"IFDs\" (image file directories). Each IFD is an object, keys are \"tXYZ\" (XYZ is a TIFF tag number), values are values of these tags. You can get the the dimension (and other properties, \"metadata\") of the image without decompressing pixel data.\n\n#### `UTIF.decodeImage(buffer, ifd)`\n* `buffer`: ArrayBuffer containing TIFF or EXIF data\n* `ifd`: the element of the output of UTIF.decode()\n* If there is an image inside the IFD, it is decoded and three new properties are added to the IFD:\n* * `width`: the width of the image\n* * `height`: the height of the image\n* * `data`: decompressed pixel data of the image\n\nTIFF files may have various number of channels and various color depth. The interpretation of `data` depends on many tags (see the [TIFF 6 specification](http://www.npes.org/pdf/TIFF-v6.pdf)). The following function converts any TIFF image into a 8-bit RGBA image.\n\n#### `UTIF.toRGBA8(ifd)`\n* `ifd`: image file directory (element of \"ifds\" returned by UTIF.decode(), processed by UTIF.decodeImage())\n* returns Uint8Array of the image in RGBA format, 8 bits per channel (ready to use in context2d.putImageData() etc.)\n\n### Example\n\n```javascript\nfunction imgLoaded(e) {\n  var ifds = UTIF.decode(e.target.response);\n  UTIF.decodeImage(e.target.response, ifds[0])\n  var rgba  = UTIF.toRGBA8(ifds[0]);  // Uint8Array with RGBA pixels\n  console.log(ifds[0].width, ifds[0].height, ifds[0]);\n}\n\nvar xhr = new XMLHttpRequest();\nxhr.open(\"GET\", \"my_image.tif\");\nxhr.responseType = \"arraybuffer\";\nxhr.onload = imgLoaded;   xhr.send();\n```\n## Use TIFF images in HTML\n\nIf you are not a programmer, you can use TIFF images directly inside the `<img>` element of HTML. Then, it is enough to call `UTIF.replaceIMG()` once at some point.\n\n#### `UTIF.replaceIMG()`\n```html\n<body onload=\"UTIF.replaceIMG()\">\n...\n<img src=\"image.tif\" />  <img src=\"dog.tif\" /> ...\n```\nAnd UTIF.js will do the rest. Internally, the \"src\" attribute of the image will be replaced with a new URI of the image (base64-encoded PNG). Note, that you can also insert DNG, CR2, NEF and other raw images into HTML this way.\n\n## Encoding TIFF images\n\nYou should not save images into TIFF format in the 21st century. Save them as PNG instead (e.g. using [UPNG.js](https://github.com/photopea/UPNG.js)). If you still want to use TIFF format for some reason, here it is.\n\n#### `UTIF.encodeImage(rgba, w, h, metadata)`\n* `rgba`: ArrayBuffer containing RGBA pixel data\n* `w`: image width\n* `h`: image height\n* `metadata` [optional]: IFD object (see below)\n* returns ArrayBuffer of the binary TIFF file. No compression right now.\n\n#### `UTIF.encode(ifds)`\n* `ifds`: array of IFDs (image file directories). An IFD is a JS object with properties \"tXYZ\" (where XYZ are TIFF tags)\n* returns ArrayBuffer of binary data. You can use it to encode EXIF data.\n\n## Dependencies\nTIFF format sometimes uses Inflate algorithm for compression (but it is quite rare). Right now, UTIF.js calls [Pako.js](https://github.com/nodeca/pako) for the Inflate method.\n","publish_time":1535835813405,"_cnpm_publish_time":1535835813405,"dist-tags":{"latest":"3.1.0"}}