{"name":"bmp-ts","version":"0.2.7","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":"7003612d791d4e36c55fe1f90bd56484d4b3bff1","bugs":{"url":"https://github.com/hipstersmoothie/bmp-ts/issues"},"homepage":"https://github.com/hipstersmoothie/bmp-ts#readme","_id":"bmp-ts@0.2.7","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-FobC49f5bZgQa3CVDD0Su8KA/zqDMLTHkQNv33x5nGYWoDvrTWhjRafPWMFp7thesugYXIRlBnxOOrGY+7yf6g==","shasum":"8c6556c3f1c39453ea2ef557fa58d29c6bd420be","tarball":"http://registry-npm.ywwl.com/bmp-ts/download/bmp-ts-0.2.7.tgz","fileCount":19,"unpackedSize":69818,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdg+W/CRA9TVsSAnZWagAA3e4QAJEOxHAR4qMu7hm6unE4\n4xDuD5w4WZ5macPTXZXr4D0CMsQCDwsCseh/1+SDI143q3hW+CbCWBYyhjgX\nCo0IQwiDTOeTe4ERInJ9++pAvsq3OB+PbACYnU6MG39hSRPXuLmYaxGjSVZg\nxn3TNRj6kjc/BWK2SAn4qpMEeeoWxqUVF8Hq9o50PEcbCtiDI7KhZWNhPRnF\nn2XyG3b9y6gc76iwOW2VbR2wkzBhaU7m5QMsgdXIiJ+FuBKH9iKHZNXy/Ktu\nIAIq+WciIsV3yijy34cWQUDWJGkj+BEQTf1dMJiJ1bX9B34ksWFfCzVINBfu\nJvjzktVzVTOrdiKLEexBdfzoV12gXsxoROgHYTHSR+HvpufsE2zT8oe9RfZU\nkrdiYKShPicblWZ+wEGLlGi6+UcCGN4nV5G6hYkgEdI5lxY5pMIScwljvCoi\n9eQxISMcA9L7/F5Z4oE2MSUsuixMdrTsd6kMnRCI7tLtZsONfnNDUM5r+VyA\nMbqg985MIineGMdhaY22uFcB54x3l+OO872BL/X/JPIWTRKyFT2X8LQLD93v\nZ62KiWteaNNG+WrSkOhM4sw94KhUyg7Tfu3n1bvvOGchBvtotfUVKM1/4/Yd\n0zuY/+U5w1oFeE+myFmZiaqNFEPiKcWuFuAYf16K8P2mHxxAcELvjkTl6OBq\naEYH\r\n=UaS9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAR1We9R5n7a6nQGfI0aml94BvsVfkG1xxtpHs98NAP9AiA7CUOrsK1a6h6L5JQyytZ95FMVAbk+8j8TnaNXZ2iPIg=="}],"size":14027,"noattachment":false,"key":"/bmp-ts/-/bmp-ts-0.2.7.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.7_1568925119007_0.11020997880080108"},"_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":1568925119165,"_cnpm_publish_time":1568925119165,"dist-tags":{"canary":"1.0.4-canary.f6048cc","latest":"1.0.9"}}