{"name":"probe-image-size","version":"1.0.0","description":"Get image size without full download (JPG, GIF, PNG, WebP, BMP, TIFF, PSD)","keywords":["image","size","jpg","jpeg","gif","png","webp","tiff","bmp","psd"],"repository":{"type":"git","url":"git+https://github.com/nodeca/probe-image-size.git"},"license":"MIT","files":["index.js","lib/"],"scripts":{"test":"make test"},"dependencies":{"async":"^1.4.2","request":"^2.60.0","stream-parser":"~0.3.1"},"devDependencies":{"eslint":"0.24.0","eslint-plugin-nodeca":"^1.0.3","mocha":"^2.2.5"},"gitHead":"962883972b67ed679c167c477c4667412efd6ba7","bugs":{"url":"https://github.com/nodeca/probe-image-size/issues"},"homepage":"https://github.com/nodeca/probe-image-size#readme","_id":"probe-image-size@1.0.0","_shasum":"3dd917def97d929f314d73f55e85512351e7a560","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"vitaly","email":"vitaly@rcdesign.ru"},"maintainers":[{"name":"vitaly","email":"vitaly@rcdesign.ru"}],"dist":{"shasum":"3dd917def97d929f314d73f55e85512351e7a560","tarball":"http://registry-npm.ywwl.com/probe-image-size/download/probe-image-size-1.0.0.tgz","integrity":"sha512-+JbUYF15eujY9idE860Ci2Lrrf5vLIiX7WTyJS4yp9qG5DXI/xNNSnovZWoBFYzfpK8iIkrCRhMH20UXQLpEUg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDjwB0iKULnrnjT+FNB4Mv24TrIr4EVST3I53r1wI2pLAiEA3zmVYWsY36cFXYSyg7VserbXNn8ofs965fqwto42PfQ="}],"size":4962,"noattachment":false,"key":"/probe-image-size/-/probe-image-size-1.0.0.tgz"},"directories":{},"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":1442012346921,"_cnpm_publish_time":1442012346921,"dist-tags":{"latest":"7.5.0"}}