{"name":"bmp-ts","version":"0.2.6","description":"A pure typescript BMP encoder and decoder","main":"dist/index.js","types":"dist/index.d.ts","license":"MIT","repository":{"type":"git","url":"git+https://github.com/hipstersmoothie/bmp-ts.git"},"author":{"name":"Andrew lisowski","email":"lisowski54@gmail.com"},"scripts":{"build":"tsc","lint":"tslint -p . --format stylish","test":"jest","release":"auto shipit"},"dependencies":{"@types/node":"^10.11.7"},"devDependencies":{"@types/jest":"^23.3.5","auto":"^7.6.0","husky":"^1.1.2","jest":"^23.6.0","lint-staged":"^7.3.0","prettier":"^1.14.3","ts-jest":"^23.10.4","tslint":"^5.11.0","tslint-config-prettier":"^1.15.0","tslint-xo":"^0.9.0","typescript":"^3.1.3"},"prettier":{"singleQuote":true},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.{js,json,css,md}":["prettier --write","git add"]},"keywords":["bmp","1bit","4bit","8bit","16bit","24bit","32bit","encoder","decoder","image","javascript","js"],"jest":{"collectCoverage":true,"coverageDirectory":"./coverage","coverageReporters":["json","lcov","text","html"],"transform":{"^.+\\.(ts|tsx)$":"ts-jest"},"testMatch":["**/*.test.+(ts|tsx|js)"],"globals":{"test-jest":{"tsConfig":"tsconfig.json"}},"moduleFileExtensions":["ts","js"],"collectCoverageFrom":["**/*.{ts,tsx}","!**/*.d.ts","!**/dist/**","!**/node_modules/**","!**/vendor/**"]},"gitHead":"15135d3ea0186a71107f1b53978f08e1cc3e7b66","bugs":{"url":"https://github.com/hipstersmoothie/bmp-ts/issues"},"homepage":"https://github.com/hipstersmoothie/bmp-ts#readme","_id":"bmp-ts@0.2.6","_nodeVersion":"12.10.0","_npmVersion":"6.10.3","dist":{"integrity":"sha512-6BLAgO2QgMLOl0DOJYJGYr5RLhv1I22uxhY3BEc3wWgpF+ZGKTmvDqfSqgYoui76YLeaiWBZQVB9QBFWOK6zZg==","shasum":"884314ada8908a1bc31caf676900c16161df3b7a","tarball":"http://registry-npm.ywwl.com/bmp-ts/download/bmp-ts-0.2.6.tgz","fileCount":19,"unpackedSize":69590,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdg+NOCRA9TVsSAnZWagAAnbIP/R8e3mHzpdxJgGOgmJMi\nJ6Pao9s6ouRVjFvoeCeLvCo2rx4pj76GLNB3KRPAuZsIbho2FVrJzplOBwf0\nFzYgUBtYT7HXOrEPFUkITs3/XC9785H+l/ynjxKIfojgC4IO/ZYr6E9zNw2r\nI+z4etP8DEBPBfKme5uXnQqaTIKLL6aypZqmuSObQ/uOm0le5ZVmShJyEoBY\n5bwCTDwM+zdro2VUDMrYocWKp8X7ePXsEzZC9APvZfaIMo6nHZX1ho67zhhR\nyKX6MMVyW+jLbyVNGvymOBDy5ZNu/r0ea/r1vV0Zsm5K20lzJSVJxVbSVYB7\ntpVj8xv6jHanvSvf8FyYokjC3Ah990M1bcmHjU31gQz5hIfQBqVyQqQ0pZ4c\nCfXQNGfo1wqJUNNxLTUsW8RzFqwx4HuhuQpZ15MMjN983IHG8G7nVIi/5UD0\nbCDwSQfUJyzCh88csjxFlbOGdM/NrmtEOe9hm5CdwZhCUWx9KsYsomqPiMUz\nfk3uaZcswbHPW8fmKtvxdu1lZiVhknX9oel8W0kHyer0p6iFuhoVR0rKoSgK\nkX3QoFPXVreNjKXoPaykY49SYVGU3CojSXLkHq0OsRhFcpuUG3LSTI9wuSDJ\nLAAsSHrsFWgGK0WhcjrTf/6imulQ+JX2MsXV9XQ8wNXlPTynhFtdmzMlfrqF\nOP+Z\r\n=7aVz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGV9/FDxjKnR94HFd3/T7+eMdhSBtCFqE84bfpnxlsGkAiEA4GnrKfM2nTpPJcoBGD901gQzCliXD2dDWyufXaplqEA="}],"size":14122,"noattachment":false,"key":"/bmp-ts/-/bmp-ts-0.2.6.tgz"},"maintainers":[{"name":"alisowski","email":"lisowski54@gmail.com"}],"_npmUser":{"name":"alisowski","email":"lisowski54@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bmp-ts_0.2.6_1568924493842_0.5918584602605326"},"_hasShrinkwrap":false,"readme":"<div align=\"center\">\n  <img width=\"200\" height=\"200\"\n    src=\"./logo.png\">\n  <h1>bmp-ts</h1>\n  <p>A pure typescript <code>bmp</code> encoder and decoder.</p>\n</div\n\n[![Codecov](https://img.shields.io/codecov/c/github/hipstersmoothie/bmp-ts.svg?style=for-the-badge)](https://codecov.io/gh/hipstersmoothie/bmp-ts)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge)](https://github.com/prettier/prettier)\n\nSupports decoding and encoding in all bit depths (1, 4, 8, 16, 24, 32).\n\n## Install\n\n```sh\nnpm install bmp-ts\n```\n\n## Usage\n\n### Decoding\n\n`decode` will return an object that includes all the header properties of the `bmp` image file and the data. See header definition [below](#header).\n\n```js\nconst bmp = require('bmp-ts').default;\nconst bmpBuffer = fs.readFileSync('bit24.bmp');\nconst bmpData = bmp.decode(bmpBuffer);\n```\n\n#### Options\n\n- toRGBA - switch the output to big endian RGBA, making it compatible with other libraries like `pngjs`\n\n```js\nconst bmp = require('bmp-ts').default;\nconst bmpBuffer = fs.readFileSync('bit24.bmp');\nconst bmpData = bmp.decode(bmpBuffer, { toRGBA: true });\n```\n\n#### Supported Compression Methods\n\nCurrently compression is only supported during decoding. The following methods are implemented:\n\n- NONE - Most common\n- BI_RLE8 - Can be used only with 8-bit/pixel bitmap\n- BI_RLE4 - Can be used only with 4-bit/pixel bitmaps\n- BI_BIT_FIELDS - Huffman 1D - BITMAPV2INFOHEADER: RGB bit field masks, BITMAPV3INFOHEADER+: RGBA\n- BI_ALPHA_BIT_FIELDS - RGBA bit field masks - only Windows CE 5.0 with .NET 4.0 or later\n\n### Encoding\n\nTo encode an image all you need is a buffer with the image data, the height and the width. You can specify the bit depth of the output image by modifying `bitPP`. If you do not provide a value, the output image defaults to 24-bit.\n\nAll header fields are valid options to `encode` and will be encoded into the header.\n\n```js\nconst bmp = require('bmp-ts').default;\nconst fs = require('fs');\nconst bmpData = {\n  data, // Buffer\n  bitPP: 1 | 2 | 4 | 16 | 24 | 32, // The number of bits per pixel\n  width, // Number\n  height, // Number\n};\n\n// Compression is not supported\nconst rawData = bmp.encode(bmpData);\nfs.writeFileSync('./image.bmp', rawData.data);\n```\n\n## Header\n\n| Property        | Type    | Purpose                                                                                                |\n| --------------- | ------- | ------------------------------------------------------------------------------------------------------ |\n| fileSize        | number  | The size of the BMP file in bytes                                                                      |\n| reserve1        | number  | Reserved; actual value depends on the application that creates the image                               |\n| reserve2        | number  | Reserved; actual value depends on the application that creates the image                               |\n| offset          | number  | The offset, i.e. starting address, of the byte where the bitmap image data (pixel array) can be found. |\n| headerSize      | number  | The size of this header (12 bytes)                                                                     |\n| width           | number  | The bitmap width in pixels (unsigned 16-bit)                                                           |\n| height          | number  | The bitmap height in pixels (unsigned 16-bit)                                                          |\n| planes          | number  | The number of color planes, must be 1                                                                  |\n| bitPP           | number  | The number of bits per pixel                                                                           |\n| compress        | number  | The compression method being used. See the supported compression methods                               |\n| rawSize         | number  | The image size. This is the size of the raw bitmap data; a dummy 0 can be given for BI_RGB bitmaps.    |\n| hr              | number  | The horizontal resolution of the image. (pixel per metre, signed integer)                              |\n| vr              | number  | The vertical resolution of the image. (pixel per metre, signed integer)                                |\n| colors          | number  | The number of colors in the color palette, or 0 to default to 2n                                       |\n| importantColors | number  | The number of important colors used, or 0 when every color is important; generally ignored             |\n| palette         | Color[] | The colors used to render the image. only used for 1, 4, and 8 bitPP images                            |\n| data            | Byte[]  | The data in ABGR                                                                                       |\n\n### Color\n\nThe color palette is returned when decoding a 1, 4, or 8 bit image.\n\nColor Format:\n\n```json\n{\n  \"red\": 255,\n  \"green\": 255,\n  \"blue\": 255,\n  \"quad\": 255\n}\n```\n\nTo encode to 4 or 8 bit a color palette must be provided. 1 bit defaults to black and white but you can override this via palette.\n\n```js\nconst rawData = bmp.encode({\n  data,\n  bitPP: 8,\n  width,\n  height,\n  palette: [\n    { red: 255, green: 255, blue: 255, quad: 0 },\n    { red: 255, green: 255, blue: 0, quad: 0 },\n    { red: 255, green: 0, blue: 255, quad: 0 },\n    { red: 255, green: 0, blue: 0, quad: 0 },\n    { red: 0, green: 255, blue: 255, quad: 0 },\n    { red: 0, green: 255, blue: 0, quad: 0 },\n    { red: 0, green: 0, blue: 255, quad: 0 },\n    { red: 0, green: 0, blue: 0, quad: 0 },\n  ],\n});\n\nfs.writeFileSync('./image.bmp', rawData.data);\n```\n","publish_time":1568924493976,"_cnpm_publish_time":1568924493976,"dist-tags":{"canary":"1.0.4-canary.f6048cc","latest":"1.0.9"}}