{"id":16129190,"url":"https://github.com/riyadhalnur/node-base64-image","last_synced_at":"2025-05-15T18:00:22.283Z","repository":{"id":24316236,"uuid":"27712409","full_name":"riyadhalnur/node-base64-image","owner":"riyadhalnur","description":"Download images from remote URLs or use local images and encode/decode them to Base64 string or Buffer object","archived":false,"fork":false,"pushed_at":"2025-04-16T15:54:11.000Z","size":1298,"stargazers_count":133,"open_issues_count":0,"forks_count":38,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-16T23:03:28.983Z","etag":null,"topics":["base64","decode","decoder","encode","encoder","javascript","nodejs","typescript"],"latest_commit_sha":null,"homepage":"http://riyadhalnur.github.io/node-base64-image","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/riyadhalnur.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":"https://www.paypal.me/afrokiddd"}},"created_at":"2014-12-08T11:49:56.000Z","updated_at":"2025-04-16T15:50:15.000Z","dependencies_parsed_at":"2024-01-14T18:45:28.242Z","dependency_job_id":"648b24f0-82b3-4c77-ab27-5828ec03bafe","html_url":"https://github.com/riyadhalnur/node-base64-image","commit_stats":{"total_commits":102,"total_committers":15,"mean_commits":6.8,"dds":0.2941176470588235,"last_synced_commit":"e6171aee545a758383a5c8027a00ccd42e3dbbca"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riyadhalnur%2Fnode-base64-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riyadhalnur%2Fnode-base64-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riyadhalnur%2Fnode-base64-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riyadhalnur%2Fnode-base64-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riyadhalnur","download_url":"https://codeload.github.com/riyadhalnur/node-base64-image/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394718,"owners_count":22063984,"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":["base64","decode","decoder","encode","encoder","javascript","nodejs","typescript"],"created_at":"2024-10-09T22:09:26.878Z","updated_at":"2025-05-15T18:00:22.271Z","avatar_url":"https://github.com/riyadhalnur.png","language":"TypeScript","readme":"![Node.js Package](https://github.com/riyadhalnur/node-base64-image/workflows/Node.js%20Package/badge.svg?branch=master)  \n![NPM Version](https://img.shields.io/npm/v/node-base64-image)\n![NPM Downloads](https://img.shields.io/npm/dw/node-base64-image)\n# node-base64-image\n\nEasily encode images (from URLs or local files) to Base64 strings or [Buffer](https://nodejs.org/api/buffer.html) objects, and decode them back into image files.\n\n### Installation\n```\nnpm install node-base64-image --save\n```\n\nUsage\n-----\n```js\n// CommonJS:\nconst { encode, decode } = require('node-base64-image');\n\n// ES Modules / TypeScript:\nimport { encode, decode } from 'node-base64-image';\n```\n\nEncodeOptions\n---\n| Attribute | Type     | Description                                | Default Value |\n|-----------|----------|--------------------------------------------|---------------|\n| string    | boolean  | If true, returns a base64 string            | false         |\n| local     | boolean  | Set to true to read from a local file       | -             |\n| timeout   | number   | Request timeout in milliseconds             | 5000          |\n| headers   | object   | Optional headers for remote HTTP requests   | -             |\n\n\nDecodeOptions (Required)\n---\n| Attribute | Type   | Description                           | Default Value |\n|-----------|--------|---------------------------------------|---------------|\n| fname     | string | Output filename (without extension)   | -             |\n| ext       | string | File extension (e.g., jpg, png)       | -             |\n\nExamples\n--------\n```js\n// encoding a remote jpg to base64\nconst url = 'https://example.com/test.jpg';\nconst options = {\n  string: true,\n  headers: {\n    \"User-Agent\": \"my-app\"\n  }\n};\nconst image = await encode(url, options);\n\n// encoding a local file\nconst localUrl = 'C:/project/test.jpg';\nconst localImage = await encode(url, {string: true, local: true});\n\n// writing to file named 'example.jpg'\nawait decode(image, { fname: 'example', ext: 'jpg' });\n\n// writing to a sub-directory\n// after creating a directory called 'photos'\nconst image = await encode(url, options);\nawait decode(image, { fname: './photos/example', ext: 'jpg' });\n```\n\n### Contributing\nRead the [CONTRIBUTING](CONTRIBUTING.md) guide for information.  \n\n### License\nLicensed under MIT. See [LICENSE](LICENSE) for more information.  \n\n### Issues\nReport a bug in [issues](https://github.com/riyadhalnur/node-base64-image/issues)\n\nMade with love in Dhaka, Bangladesh by [Riyadh Al Nur](https://verticalaxisbd.com)\n","funding_links":["https://www.paypal.me/afrokiddd"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friyadhalnur%2Fnode-base64-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friyadhalnur%2Fnode-base64-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friyadhalnur%2Fnode-base64-image/lists"}