{"id":13402642,"url":"https://github.com/nodeca/probe-image-size","last_synced_at":"2025-05-14T08:06:23.422Z","repository":{"id":46582295,"uuid":"42185437","full_name":"nodeca/probe-image-size","owner":"nodeca","description":"Get image size without full download. Supported image types: JPG, GIF, PNG, WebP, BMP, TIFF, SVG, PSD, ICO.","archived":false,"fork":false,"pushed_at":"2023-06-19T03:12:21.000Z","size":366,"stargazers_count":992,"open_issues_count":6,"forks_count":77,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-12T12:54:42.619Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nodeca.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"open_collective":"puzrin","patreon":"puzrin","tidelift":"npm/probe-image-size"}},"created_at":"2015-09-09T14:58:18.000Z","updated_at":"2025-05-09T12:53:22.000Z","dependencies_parsed_at":"2023-02-16T05:15:38.328Z","dependency_job_id":"7ca10c41-b631-426d-b26d-1286b4ac2525","html_url":"https://github.com/nodeca/probe-image-size","commit_stats":{"total_commits":176,"total_committers":12,"mean_commits":"14.666666666666666","dds":"0.25568181818181823","last_synced_commit":"158c262a7e58b8e3abd7573e2d854299146fcc37"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodeca%2Fprobe-image-size","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodeca%2Fprobe-image-size/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodeca%2Fprobe-image-size/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodeca%2Fprobe-image-size/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodeca","download_url":"https://codeload.github.com/nodeca/probe-image-size/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253805845,"owners_count":21967054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T19:01:18.777Z","updated_at":"2025-05-14T08:06:23.380Z","avatar_url":"https://github.com/nodeca.png","language":"JavaScript","funding_links":["https://opencollective.com/puzrin","https://patreon.com/puzrin","https://tidelift.com/funding/github/npm/probe-image-size","https://tidelift.com/subscription/pkg/npm-probe-image-size?utm_source=npm-probe-image-size\u0026utm_medium=referral\u0026utm_campaign=readme"],"categories":["JavaScript","Packages","Repository","包","目录","Image","Uncategorized"],"sub_categories":["Image","图像","图像处理","Uncategorized"],"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\u003e Get image size without full download. Supported image types:\n\u003e 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); // =\u003e\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]) -\u003e 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 \u003e= 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) -\u003e 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 \u0026 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\u0026utm_medium=referral\u0026utm_campaign=readme).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodeca%2Fprobe-image-size","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodeca%2Fprobe-image-size","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodeca%2Fprobe-image-size/lists"}