{"id":15685954,"url":"https://github.com/jaywcjlove/image2uri","last_synced_at":"2025-06-24T14:36:48.703Z","repository":{"id":42062608,"uuid":"287724013","full_name":"jaywcjlove/image2uri","owner":"jaywcjlove","description":"Convert image file to data URI.","archived":false,"fork":false,"pushed_at":"2024-10-29T02:47:48.000Z","size":136,"stargazers_count":10,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T23:24:25.528Z","etag":null,"topics":["image","image2uri","jpeg","nodejs","png","uri"],"latest_commit_sha":null,"homepage":"https://jaywcjlove.github.io/image2uri/","language":"TypeScript","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/jaywcjlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"jaywcjlove","buy_me_a_coffee":"jaywcjlove","custom":["https://www.paypal.me/kennyiseeyou","https://jaywcjlove.github.io/#/sponsor"]}},"created_at":"2020-08-15T10:21:06.000Z","updated_at":"2025-02-06T15:48:27.000Z","dependencies_parsed_at":"2024-11-11T17:32:21.986Z","dependency_job_id":"f18f15af-6500-42e1-bda5-795c0d27bd55","html_url":"https://github.com/jaywcjlove/image2uri","commit_stats":{"total_commits":53,"total_committers":3,"mean_commits":"17.666666666666668","dds":0.05660377358490565,"last_synced_commit":"6b8bafa9f92297052f49555da13c2377fd4106bc"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2Fimage2uri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2Fimage2uri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2Fimage2uri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2Fimage2uri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaywcjlove","download_url":"https://codeload.github.com/jaywcjlove/image2uri/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248979844,"owners_count":21193050,"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":["image","image2uri","jpeg","nodejs","png","uri"],"created_at":"2024-10-03T17:33:40.910Z","updated_at":"2025-04-16T01:19:20.278Z","avatar_url":"https://github.com/jaywcjlove.png","language":"TypeScript","funding_links":["https://ko-fi.com/jaywcjlove","https://buymeacoffee.com/jaywcjlove","https://www.paypal.me/kennyiseeyou","https://jaywcjlove.github.io/#/sponsor"],"categories":[],"sub_categories":[],"readme":"Image To URI\n===\n\n[![Buy me a coffee](https://img.shields.io/badge/Buy%20me%20a%20coffee-048754?logo=buymeacoffee)](https://jaywcjlove.github.io/#/sponsor)\n[![NPM Downloads](https://img.shields.io/npm/dm/image2uri.svg?style=flat)](https://www.npmjs.com/package/image2uri)\n[![Build \u0026 Test](https://github.com/jaywcjlove/image2uri/actions/workflows/ci.yml/badge.svg)](https://github.com/jaywcjlove/image2uri/actions/workflows/ci.yml)\n[![npm version](https://img.shields.io/npm/v/image2uri.svg)](https://www.npmjs.com/package/image2uri)\n[![Coverage Status](https://jaywcjlove.github.io/image2uri/badges.svg)](https://jaywcjlove.github.io/image2uri/lcov-report/)\n\nConvert image file to data URI. Support `.png`,`.gif`,`.jpg`,`.jpeg`,`.bm`,`.bmp`,`.webp`,`.ico`,`.svg`.\n\n### Install\n\nThis package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): Node 12+ is needed to use it and it must be import instead of require.\n\n```bash\nnpm i image2uri\n```\n\n```js\nconst recursiveReaddirFiles = await import('image2uri');\n\n// Fix compiling in typescript.\n// https://github.com/microsoft/TypeScript/issues/43329#issuecomment-922544562\nconst { getExt, recursiveReaddirFiles } = await (Function('return import(\"image2uri\")')()) as Promise\u003ctypeof import(\"image2uri\")\u003e;\n```\n\n### Basic Usage\n\n```js\nimport image2uri from \"image2uri\";\n\nconsole.log(image2uri('./example.bmp'));\n// data:image/bmp;base64,Qk0YCAAAAAAAADYAAAAoAAAAGAAAABwAAAABABgAAAAAAOIHAAA....\nconsole.log(image2uri('./example.jpg'));\n// data:image/jpeg;base64,Qk0YCAAAAAAAADYAAAAoAAAAGAAAABwAAAABABgAAAAAAOIHAAA....\n\nconst uri = await image2uri('https://avatars.githubusercontent.com/u/1680273?v=4', { ext: '.apng' });\n// data:image/apng;base64,/9j/2wCEAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDc\nconst avatar = await image2uri('https://avatars.githubusercontent.com/u/1680273?v=4');\n// /9j/2wCEAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDc\n```\n\n### API\n\n```ts\nexport declare const validUrl: (url: string) =\u003e boolean;\nexport declare const extTypeMap: {\n    '.png': string;\n    '.apng': string;\n    '.gif': string;\n    '.jpg': string;\n    '.jpeg': string;\n    '.bm': string;\n    '.bmp': string;\n    '.webp': string;\n    '.ico': string;\n    '.svg': string;\n};\nexport type ExtType = keyof typeof extTypeMap;\nexport default function image2uri(file: string, options?: {\n    ext?: string;\n}): string | Promise\u003cstring\u003e;\n```\n\n### Development\n\n```bash\nnpm run watch # Listen compile .ts files.\nnpm run build # compile .ts files.\n\nnpm run start\n```\n\n### Related\n\n- [recursive-readdir-files](https://github.com/jaywcjlove/recursive-readdir-files) Node.js module to list all files in a directory or any subdirectories.\n\n## Contributors\n\nAs always, thanks to our amazing contributors!\n\n\u003ca href=\"https://github.com/jaywcjlove/image2uri/graphs/contributors\"\u003e\n  \u003cimg src=\"https://jaywcjlove.github.io/image2uri/CONTRIBUTORS.svg\" /\u003e\n\u003c/a\u003e\n\nMade with [action-contributors](https://github.com/jaywcjlove/github-action-contributors).\n\n### License\n\nLicensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaywcjlove%2Fimage2uri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaywcjlove%2Fimage2uri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaywcjlove%2Fimage2uri/lists"}