{"name":"probe-image-size","version":"7.1.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":{"lodash.merge":"^4.6.2","needle":"^2.5.2","stream-parser":"~0.3.1"},"devDependencies":{"eslint":"^7.12.1","mocha":"^8.2.0","nyc":"^15.1.0"},"gitHead":"9b04ee8afb367c91efca52919d232593b2613ffd","bugs":{"url":"https://github.com/nodeca/probe-image-size/issues"},"homepage":"https://github.com/nodeca/probe-image-size#readme","_id":"probe-image-size@7.1.1","_nodeVersion":"14.16.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-lvpHKqtino5SSrFEKxFncco8raLywljcLbjcE35VIRl5O+u1qLXenNaEfnopYdJgN4PPvvBxdr8b7sEUTvfY/w==","shasum":"ea3dc7acd69fb041212de12bb390be58c1025917","tarball":"http://registry-npm.ywwl.com/probe-image-size/download/probe-image-size-7.1.1.tgz","fileCount":33,"unpackedSize":74846,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgr+FZCRA9TVsSAnZWagAAMLoP/2HsnwBLdEW+ObkZRgmA\njdiTHQODOvWgeZFT60636pmySBSMsNFCmaBwya03NDesOFJcQTgo75HepW3v\nvNU7JCctHD0GgauAuIGLPBLxq812lYUzOyqNOwAFzTC425Y6XG4Qg5CJo1v/\npYcNl5K32ivK5I5iWOuPx/eGTho5mYESX26jzZBVUt/1q+xzcx2AkjNzOXJR\ns0zP3JKqrVd6OZYawChmKG6puMv0Kn1ycFaOGRTwUpF4nbhx3V1UU3vnsu2D\nJgYJ8ZA9IhL2VyaWfEyUMLcBP/tWQmlZadoh/ShcY6DiPdhFQdk/0XNf5Iau\n9K8uKzVMoau/R+hgkGTX8e05hBGOHoK1qI/bopLoCmr5eM2YERVdVwBXa6j+\nikA3VE1bF8BEP8TBIxj8eHXol1+WZAE7fEhzEC7HD8wSFUHdYB8gH8s2nyvF\n8Nf/3sVWx15mC7Lt3hUtr9Use3QPYd1mlq5LXnAxQL8EQMU1zUFbLyIpkgAG\nG+gP9yolaHy++cnnwY7vh+axvWpx/+3N93AVWW+lhxWwgLUFHet7gZI82nc7\n2vhV8Z72Z0mbJQx0zQQo2WBzpRIbb+IfOS5p8Hia/Cz7piHcd+Xlu46qmFln\nm5ISsyABcJtXZH2T7k1kwusdkarhC5qgjQogzO1Yi5xAU+np9aBudy0VA1ZP\neGN2\r\n=DS/9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCSmgljrG79KSzpoAR1WPzX7UN9clJOCl9E0QINnLnGvAIgH4tFpZEhuPg8jLTCbUvaYDX+sNmnzHF5r1pCn+agYFI="}],"size":18992,"noattachment":false,"key":"/probe-image-size/-/probe-image-size-7.1.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.1.1_1622139225025_0.5416270589204777"},"_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":1622139225220,"_cnpm_publish_time":1622139225220,"dist-tags":{"latest":"7.5.0"}}