{"_id":"utif2","_rev":"3016183","name":"utif2","description":"Fast and advanced TIFF decoder","dist-tags":{"latest":"4.1.0"},"maintainers":[{"name":"jbereza","email":""}],"time":{"modified":"2023-10-13T08:34:19.000Z","created":"2022-05-04T22:24:08.750Z","4.1.0":"2023-05-06T16:57:07.182Z","4.0.1":"2022-05-04T22:32:15.174Z","4.0.0":"2022-05-04T22:24:08.750Z"},"users":{},"author":{"name":"photopea","url":"https://github.com/photopea"},"repository":{"type":"git","url":"git+https://github.com/photopea/UTIF.js.git"},"versions":{"4.1.0":{"name":"utif2","description":"Fast and advanced TIFF decoder","version":"4.1.0","homepage":"https://github.com/photopea/UTIF.js","author":{"name":"photopea","url":"https://github.com/photopea"},"contributors":[{"name":"Photopea","url":"https://github.com/photopea"},{"name":"Jaroslav Bereza","url":"https://github.com/jardicc"},{"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":["tif","tiff","image","conversion"],"dependencies":{"pako":"^1.0.11"},"types":"./UTIF.d.ts","_id":"utif2@4.1.0","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"shasum":"e768d37bd619b995d56d9780b5d2b4611a3d932b","size":34612,"noattachment":false,"key":"/utif2/-/utif2-4.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/utif2/download/utif2-4.1.0.tgz"},"_npmUser":{"name":"jbereza","email":"j@bereza.cz"},"directories":{},"maintainers":[{"name":"jbereza","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utif2_4.1.0_1683392226958_0.944401727404161"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-05-06T16:57:07.182Z","publish_time":1683392227182,"_source_registry_name":"default","_cnpm_publish_time":1683392227182},"4.0.1":{"name":"utif2","description":"Fast and advanced TIFF decoder","version":"4.0.1","homepage":"https://github.com/photopea/UTIF.js","author":{"name":"photopea","url":"https://github.com/photopea"},"contributors":[{"name":"Photopea","url":"https://github.com/photopea"},{"name":"Jaroslav Bereza","url":"https://github.com/jardicc"},{"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":["tif","tiff","image","conversion"],"dependencies":{"pako":"^1.0.11"},"types":"./UTIF.d.ts","_id":"utif2@4.0.1","_nodeVersion":"16.13.0","_npmVersion":"8.1.0","dist":{"shasum":"562433ef58d76b16d85638f052b2d8486122062c","size":31318,"noattachment":false,"key":"/utif2/-/utif2-4.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/utif2/download/utif2-4.0.1.tgz"},"_npmUser":{"name":"jbereza","email":"j@bereza.cz"},"directories":{},"maintainers":[{"name":"jbereza","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utif2_4.0.1_1651703534998_0.9087714293429503"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-04T22:32:23.930Z","publish_time":1651703535174,"_cnpm_publish_time":1651703535174},"4.0.0":{"name":"utif2","description":"Fast and advanced TIFF decoder","version":"4.0.0","homepage":"https://github.com/photopea/UTIF.js","author":{"name":"photopea","url":"https://github.com/photopea"},"contributors":[{"name":"Photopea","url":"https://github.com/photopea"},{"name":"Jaroslav Bereza","url":"https://github.com/jardicc"},{"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":["tif","tiff","image","conversion"],"dependencies":{"pako":"^1.0.11"},"_id":"utif2@4.0.0","_nodeVersion":"16.13.0","_npmVersion":"8.1.0","dist":{"shasum":"fc8f2f3c225518bb901ce50355cf2625446ec4ca","size":30602,"noattachment":false,"key":"/utif2/-/utif2-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/utif2/download/utif2-4.0.0.tgz"},"_npmUser":{"name":"jbereza","email":"j@bereza.cz"},"directories":{},"maintainers":[{"name":"jbereza","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utif2_4.0.0_1651703048556_0.2162397144541981"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-04T22:27:43.803Z","publish_time":1651703048750,"_cnpm_publish_time":1651703048750}},"readme":"\n# UTIF2\n## This is newer version of [UTIF](https://www.npmjs.com/package/utif)\n\nSince last update of UTIF was 18/6/2019 and [Photopea does not touch npm](https://github.com/photopea/UTIF.js/issues/106) at all and neither 3rd party developer is keeping package up to date with GitHub repo... this package is just updated version of utif (from npm) but with many improvements.\n\n## About\n\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","_attachments":{},"homepage":"https://github.com/photopea/UTIF.js","bugs":{"url":"https://github.com/photopea/UTIF.js/issues"},"license":"MIT"}