{"id":18408136,"url":"https://github.com/area44/node-image-meta-fetcher","last_synced_at":"2026-05-07T08:36:11.332Z","repository":{"id":192932221,"uuid":"640319819","full_name":"AREA44/node-image-meta-fetcher","owner":"AREA44","description":"Fetch metadata for images in a directory","archived":false,"fork":false,"pushed_at":"2025-04-06T06:34:55.000Z","size":881,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T21:17:46.490Z","etag":null,"topics":["dimensions","json","nodejs","plaiceholder","sharp"],"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/AREA44.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-13T17:35:13.000Z","updated_at":"2025-04-06T06:34:58.000Z","dependencies_parsed_at":"2023-10-16T10:56:23.818Z","dependency_job_id":"542c8dfb-5fe2-47e0-8a66-2ba0eb96cce9","html_url":"https://github.com/AREA44/node-image-meta-fetcher","commit_stats":null,"previous_names":["area44/node-image-meta-fetcher"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AREA44%2Fnode-image-meta-fetcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AREA44%2Fnode-image-meta-fetcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AREA44%2Fnode-image-meta-fetcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AREA44%2Fnode-image-meta-fetcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AREA44","download_url":"https://codeload.github.com/AREA44/node-image-meta-fetcher/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631688,"owners_count":21136562,"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":["dimensions","json","nodejs","plaiceholder","sharp"],"created_at":"2024-11-06T03:17:14.225Z","updated_at":"2026-05-07T08:36:11.326Z","avatar_url":"https://github.com/AREA44.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📸 Image Meta Fetcher\r\n\r\n**Image Meta Fetcher** is a lightweight Node.js utility that extracts image metadata from a folder using [Sharp](https://github.com/lovell/sharp) — including image dimensions, format, and a base64-encoded thumbnail preview.\r\n\r\nIt’s ideal for static site generators, gallery builders, or scripts that need fast metadata and previews without loading full images in the browser.\r\n\r\n## ⚡ Features\r\n\r\n* 🔍 Extracts width, height, format\r\n* 🖼️ Generates base64 previews (default size: 10×10)\r\n* 📁 Supports glob patterns (e.g. `images/*.{jpg,png}`)\r\n* ⚙️ Optional resizing and sorting\r\n* 🧪 Tested with [Vitest](https://vitest.dev/)\r\n* 🔧 Built with [Bun](https://bun.sh)\r\n\r\n## 🚀 Getting Started\r\n\r\n### 1. Clone the repository\r\n\r\n```bash\r\ngit clone https://github.com/AREA44/node-image-meta-fetcher\r\ncd node-image-meta-fetcher\r\n```\r\n\r\n### 2. Install dependencies\r\n\r\n```bash\r\nbun install\r\n```\r\n\r\n## 🖼️ Usage Example\r\n\r\nAdd images (`.jpg`, `.jpeg`, `.png`, `.webp`) to the `examples/assets/` folder.\r\n\r\n### Run the basic example:\r\n\r\n```bash\r\nbun run examples/basic.js\r\n```\r\n\r\nThis will print image metadata to the console.\r\n\r\n### Run with custom options:\r\n\r\n```bash\r\nbun run examples/options.js\r\n```\r\n\r\nThis will:\r\n\r\n* Resize each preview to `20x20`\r\n* Disable filename sorting\r\n* Write the result to `examples/output/thumbnails.json`\r\n\r\n## 📦 Output Format\r\n\r\nEach image is returned as an object like:\r\n\r\n```json\r\n{\r\n  \"src\": \"example.jpg\",\r\n  \"width\": 1024,\r\n  \"height\": 768,\r\n  \"format\": \"jpeg\",\r\n  \"base64\": \"data:image/jpeg;base64,...\"\r\n}\r\n```\r\n\r\n| Field    | Description                                            |\r\n| -------- | ------------------------------------------------------ |\r\n| `src`    | File name (e.g. `photo.jpg`)                           |\r\n| `width`  | Original width in pixels                               |\r\n| `height` | Original height in pixels                              |\r\n| `format` | File format (`jpeg`, `png`, `webp`, etc.)              |\r\n| `base64` | Base64 preview of a resized thumbnail (default: 10×10) |\r\n\r\n## 📚 API\r\n\r\n```js\r\nImageMetaFetcher(globPattern, options?)\r\n```\r\n\r\n| Parameter     | Type                   | Description                                       |\r\n| ------------- | ---------------------- | ------------------------------------------------- |\r\n| `globPattern` | `string` or `string[]` | File path(s) to match (e.g. `images/*.{jpg,png}`) |\r\n| `options`     | `object`               | Optional configuration                            |\r\n\r\n### Options\r\n\r\n```js\r\n{\r\n  resize: {\r\n    width: 10,\r\n    height: 10,\r\n    fit: \"inside\" // or \"cover\", \"contain\", etc. (from sharp)\r\n  },\r\n  sort: true // sort results by filename\r\n}\r\n```\r\n\r\n## 🧪 Running Tests\r\n\r\nRun the full test suite:\r\n\r\n```bash\r\nbun test\r\n```\r\n\r\nWatch mode:\r\n\r\n```bash\r\nbun test:watch\r\n```\r\n\r\nTests cover:\r\n\r\n* Basic metadata extraction\r\n* Sorting\r\n* Thumbnail resizing\r\n* Handling invalid/corrupt images\r\n\r\n## 📁 Project Structure\r\n\r\n```\r\n.\r\n├── examples/\r\n│   ├── assets/              # Sample input images\r\n│   ├── basic.js             # Basic usage example\r\n│   └── options.js           # Example with custom options\r\n├── tests/\r\n│   ├── fixtures/            # Test images (valid + broken)\r\n│   └── ImageMetaFetcher.test.js\r\n├── index.js                 # Main module\r\n├── README.md\r\n└── package.json\r\n```\r\n\r\n## 📄 License\r\n\r\nMIT © [AREA44](https://github.com/area44)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farea44%2Fnode-image-meta-fetcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farea44%2Fnode-image-meta-fetcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farea44%2Fnode-image-meta-fetcher/lists"}