{"name":"utif","description":"Fast and advanced TIFF decoder","version":"3.0.0","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":"a91099f1888e0d77cda228d71ef213b9b308b3bb","_id":"utif@3.0.0","_npmVersion":"6.4.0","_nodeVersion":"10.9.0","_npmUser":{"name":"scimonster","email":"tehalmightyscimonster@gmail.com"},"dist":{"integrity":"sha512-rAdBSYyqIbU7hFV38pibD9kyYBuzshrWa2jNhE/17YWe8DqI0/JSDBcL3GN48DvG04JC2ecG4Xu0XcQZnEGLdg==","shasum":"94fead8cfcbfa9687d679307fbc41d635c1376e1","tarball":"http://registry-npm.ywwl.com/utif/download/utif-3.0.0.tgz","fileCount":4,"unpackedSize":60596,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcYYCHCRA9TVsSAnZWagAAbVUQAJHrNcw5X6fog+Z8IMa6\nEpeIbSGmM6oACCINvb2dkod5TC505526Gt8LlEunfDH/XA5ZmTJEoUXuMunw\n/wq4DvDEF0qFN3aV6CS6pOLEiPpy1A3Md1knkPOmH8CGhg9QG3CdCRuk3LLp\nOt4dO27/3bCQHXDWQQMzyr85jpVrm+v+uM83KYc0lpez8Tv/oNXfzgniRX/o\nlQ3QihMN+zskVH1kaYcFnqp99ZErQUArjiT/neNT+5e5hfzBbFEX03D+x73e\nrGKrrgZ4oD+IhYS5wKDbzrwUDlc9b7KpSPsAD/TaJ/ROMaoxJBnRR/gdJ+tF\nRykDLRaD3HgPRHpo4rcCQm0FJMPoMlRe9OXzFEgtawYa7C14V4Re7k/37eEy\nZG60PLD59BiXK0TRAom2IoP4UaMIHCFAWDOuNKam2i7ESGshNGRiZ4y5VjtH\nSMpDtrpWJWcRIDU/DpqjU7y56bsoYiSep1giH5O07+/PSMfH8u4nYo6HZnJq\nqWuIUSCRYwhvS9Mbjmjqy1S2pGYf7P4kR7U1H8+rKtews40ciFowlw0rhkLo\nrdsLQRX8c5dMpCDK82fGX8A/430RpnjYkiewaZ3KmFV2K7NG1BA6qV9UViT6\nEOK5MONvmpme2IGJKOEPYMJQKyXaCjwvhZcPpVH9rcRuQ5dzfIPW2SFV5FHm\n00BK\r\n=O6U9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAwOP7ehxWjwdzi0YRTzFDJwz3zSKlRVIM46NUH5XI6vAiEAuihJZSSblocS1hDLeZYcfcut/Q2F9WauAGkq/D4hjCE="}],"size":21178,"noattachment":false,"key":"/utif/-/utif-3.0.0.tgz"},"maintainers":[{"name":"photopea","email":"support@photopea.com"},{"name":"scimonster","email":"tehalmightyscimonster@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utif_3.0.0_1549893766856_0.05824767314241264"},"_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":1549893766994,"_cnpm_publish_time":1549893766994,"dist-tags":{"latest":"3.1.0"}}