{"name":"probe-image-size","version":"7.0.1","description":"Get image size without full download (JPG, GIF, PNG, WebP, BMP, TIFF, PSD)","keywords":["image","size","jpg","jpeg","ico","gif","png","webp","tiff","bmp","svg","psd"],"repository":{"type":"git","url":"git+https://github.com/nodeca/probe-image-size.git"},"license":"MIT","scripts":{"lint":"eslint .","test":"npm run lint && nyc mocha","coverage":"npm run test && nyc report --reporter html","report-coveralls":"nyc --reporter=lcov mocha"},"mocha":{"timeout":5000},"dependencies":{"deepmerge":"^4.0.0","needle":"^2.5.2","stream-parser":"~0.3.1"},"devDependencies":{"eslint":"^7.12.1","mocha":"^8.2.0","nyc":"^15.1.0"},"gitHead":"75f24a4d139a9242c8b7925d1e51c3ff64adb9ac","bugs":{"url":"https://github.com/nodeca/probe-image-size/issues"},"homepage":"https://github.com/nodeca/probe-image-size#readme","_id":"probe-image-size@7.0.1","_nodeVersion":"14.16.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-4ua2TGdO761JWaTgbLD2Uq9yFvB34QBAxnqz9GOs3w4+SC4dfbQcnnNY8loHjZV5NRW8PSQRz+WZ6NfUvbuRDA==","shasum":"ac815d78bdf8c5643af6e541a572c0077c75f2c1","tarball":"http://registry-npm.ywwl.com/probe-image-size/download/probe-image-size-7.0.1.tgz","fileCount":33,"unpackedSize":73490,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgU21MCRA9TVsSAnZWagAAlNMP/2iXoh2p1hoWeNcRfOOU\nHivh5Xka8U3qTod31MHGcmf24JRwe+ato4K5vGhO76nkNZfi6UmB6Y6FisuT\n9DcWWGdkasJNbQAS6cswQCoKWYW7oB17Ktv5MCyQV52qjHwa4gZNWp+Opu7U\nSOPmR/aLGgo+myl5ciykdCqIo2//Ox5nP3mg7R9rDdbH9lZaVwdoIDWM/DKC\nyIO+HNWRJT7XjcWpvWafkj9GwftAti1cTFwU4AS+lVD+ojyCRIpQaoIG58xx\nN4SaV4drs8bpecjRj+tJxC6GoFBEgkRvWqi1EBGPi3HmVeBBsDJN6gLkI3+I\nEYkqRN3IbyR7+vJNJ+8oj+iJKYqan4+GdnalEbIp8UsB5evZG6rz8TQW60MQ\nCb28zAL04DO3C3CEmX9H49Z/DNXt9wnvmQGDpofbO0pUX5bX3sjnTtJn75VX\ndsdFzW8OZfHSOME3uEBuaqlCKVflvZdXuzyAW0fUXGSO2W7s0trYupO1fC9a\n3MpAJQmBHJOAkisxppGLINlgMGxknyGDz3RoFpua6+DZNnKuoEXEYSgYZwX6\n7eoqR0GjoZT6x47jlMR8/OvCxhsLmqmvCEcEzMYRjXif7Ycz5j6bqWoOY0vn\nGb0zKzutErmWp9QqGNYmlJ+wuFLJgbi2rccJicBZHoFHqp55wQ1JxqB05So5\nK1v9\r\n=wM4C\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAJ5jOTXzTgI1XNWkXEfSfbnwwAC+qzr66pgtKj2BKR1AiEA21QF1jb2MyZ8wvZ714sV9VNeVyuocz2HSu3KG3vWUfY="}],"size":18634,"noattachment":false,"key":"/probe-image-size/-/probe-image-size-7.0.1.tgz"},"_npmUser":{"name":"vitaly","email":"vitaly@rcdesign.ru"},"directories":{},"maintainers":[{"name":"vitaly","email":"vitaly@rcdesign.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/probe-image-size_7.0.1_1616080204230_0.5676101693037441"},"_hasShrinkwrap":false,"readme":"probe-image-size\n================\n\n[![CI](https://github.com/nodeca/probe-image-size/workflows/CI/badge.svg?branch=master)](https://github.com/nodeca/probe-image-size/actions)\n[![NPM version](https://img.shields.io/npm/v/probe-image-size.svg?style=flat)](https://www.npmjs.org/package/probe-image-size)\n[![Coverage Status](https://coveralls.io/repos/github/nodeca/probe-image-size/badge.svg?branch=master)](https://coveralls.io/github/nodeca/probe-image-size?branch=master)\n\n> Get image size without full download. Supported image types:\n> JPG, GIF, PNG, WebP, BMP, TIFF, SVG, PSD, ICO, AVIF, HEIC, HEIF.\n\nKey features:\n\n- small size, no heavy dependencies\n- works with remote and local data\n- effective with big images (speed/memory), download minimal data from remotes\n- extracts orientation value when available\n- easy to browserify (splitted to components)\n\n\nInstall\n-------\n\n```bash\nnpm install probe-image-size\n```\n\nExample\n-------\n\n```js\nconst probe = require('probe-image-size');\n\n// Get by URL\nlet result = await probe('http://example.com/image.jpg');\nconsole.log(result); // =>\n/*\n  {\n    width: xx,\n    height: yy,\n    type: 'jpg',\n    mime: 'image/jpeg',\n    wUnits: 'px',\n    hUnits: 'px',\n    url: 'http://example.com/image.jpg'\n  }\n*/\n\n\n// By URL with options\nlet result = await probe('http://example.com/image.jpg', { rejectUnauthorized: false });\nconsole.log(result);\n\n\n// From the stream\nlet result = await probe(require('fs').createReadStream('image.jpg'));\nconsole.log(result);\n\n\n// From a Buffer (sync)\nlet data = require('fs').readFileSync('image.jpg');\nconsole.log(probe.sync(data));\n```\n\n\nAPI\n---\n\nNote:\n\n- You can access/browserify `stream.js` / `http.js` / `sync.js` directly.\n- If you don't like `http.js` dependencies, you can create your own wrapper\n  for `stream.js`.\n\n### probe(src [, options|keepOpen]) -> Promise\n\n- `src` can be of this types:\n  - _String_ - URL to fetch\n  - _Stream_ - readable stream\n- `options` - HTTP only. See [`needle` documentation](https://github.com/tomas/needle#request-options), and customized [defaults](https://github.com/nodeca/probe-image-size/blob/master/http.js#L13).\n- `keepOpen` (Boolean) - stream only. Keep stream open after parser finishes\n  (input stream will be closed by default)\n\n`result` (Promise) contains:\n\n```js\n{\n  width: XX,\n  height: YY,\n  length: ZZ,   // byte length of the file (if available, HTTP only)\n  type: ...,    // image 'type' (usual file name extention)\n  mime: ...,    // mime type\n  wUnits: 'px', // width units type ('px' by default, can be different for SVG)\n  hUnits: 'px', // height units type ('px' by default, can be different for SVG)\n  url: ...,     // HTTP only, last url for the image in chain of redirects\n                // (if no redirects, same as src)\n\n  // optional, image orientation (from Exif), number from 1 to 8;\n  // you may wish to swap width and height if orientation is >= 5\n  orientation: X,\n\n  // optional, full list of sizes for ICO (always) and AVIF (if multiple images)\n  variants: [ { width, height }, ... ] | undefined\n}\n```\n\nWidth and height in the output object represent image size *before* any transformations\n(orientation, cropping) are applied. Orientation is returned separately, which you may\nwish to apply afterwards depending on browser support (browsers\n[only support JPEG](https://zpl.fi/exif-orientation-in-different-formats/) orientation for now).\nSee [known issues](known_issues.md) for details.\n\nReturned errors can be extended with 2 fields:\n\n- `code` - equals to `ECONTENT` if the library failed to parse the file;\n- `status` - equals to a HTTP status code if it receives a non-200 response.\n\n\n### probe.sync(src) -> result|null\n\nSync version can eat arrays, typed arrays and buffers. On success it returns\nthe same result as async version. On fail it returns null.\n\n__Note.__ Formats like JPEG & TIFF can store size anywhere (far from the head).\nThat usually does not happens, but if you need guarantees - always provide full\nfile content to sync methods. We strongly recommend to use async version\nas memory-friendly.\n\n\nSimilar projects\n----------------\n\n- [image-size](https://github.com/netroy/image-size)\n\n\nSupport probe-image-size\n------------------------\n\nYou can support this project via [Tidelift subscription](https://tidelift.com/subscription/pkg/npm-probe-image-size?utm_source=npm-probe-image-size&utm_medium=referral&utm_campaign=readme).\n","publish_time":1616080204384,"_cnpm_publish_time":1616080204384,"dist-tags":{"latest":"7.5.0"}}