{"id":20288002,"url":"https://github.com/dopecodez/base64-image","last_synced_at":"2025-07-16T15:41:33.508Z","repository":{"id":55538200,"uuid":"294020426","full_name":"dopecodez/base64-image","owner":"dopecodez","description":"A base64 to image and vice versa converter using latest ES6.","archived":false,"fork":false,"pushed_at":"2022-12-29T07:15:47.000Z","size":250,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-26T23:03:35.433Z","etag":null,"topics":["base64","base64-decoding","base64-encoding","base64-image","base64-tool","image-base64"],"latest_commit_sha":null,"homepage":"","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/dopecodez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-09T06:15:08.000Z","updated_at":"2024-03-23T09:23:47.000Z","dependencies_parsed_at":"2023-01-31T08:15:36.600Z","dependency_job_id":null,"html_url":"https://github.com/dopecodez/base64-image","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopecodez%2Fbase64-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopecodez%2Fbase64-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopecodez%2Fbase64-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopecodez%2Fbase64-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dopecodez","download_url":"https://codeload.github.com/dopecodez/base64-image/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248372134,"owners_count":21093133,"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","base64-decoding","base64-encoding","base64-image","base64-tool","image-base64"],"created_at":"2024-11-14T14:43:40.674Z","updated_at":"2025-04-11T10:00:21.740Z","avatar_url":"https://github.com/dopecodez.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NODE-BASE64-IMG [![build](https://github.com/dopecodez/base64-image/workflows/build/badge.svg)](https://github.com/dopecodez/base64-image/actions) [![Contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dopecodez/base64-image/issues)\n\nA base64-image converter and vice-versa for node with modern ES6.\n\nConvert your base64 strings to images or convert your images to base64 string. Build with native support for async/await and promises. Supports png, jpg, jpeg and gif images.\n\nNewly released and actively maintained. Small unpacked size.\n\n# INSTALLATION\n\n```\n$ npm install node-base64-img\n```\n\n## Highlights\n\n- [base64Img](#base64Img)\n- [toBase64](#toBase64)\n- [Contributing](#contributing)\n\n## base64Img\n\nIt's a simple library with two functions plus types exposed.\n\n```js\nconst base64Img = require('base64img');\n\n(async () =\u003e {\n\ttry {\n\t\tconst response = await base64Img('base64String', './', 'sample', {type: 'jpeg'});\t\n\t} catch (error) {\n\t\tconsole.log(error);\n\t\t//=\u003e 'Internal server error ...'\n\t}\n})();\n```\nThe first argument for the default function is the `base64` string. This can be any valid base64 string, it will throw an error in case the base64 is invalid.\n\nThe second argument is the path where you want to save the image. This can be relative or absolute.\n\nThe third argument is the filename which can be any valid string.\n\nThe method will return a `base64ImgResult` object type which is exported in `types`.\n\n```ts\ninterface base64ImgResult {\n    path: string,\n    mimeType: string\n}\n```\nThe mimeType and path parameters can be useful in case you want to save the path or know what type your image was saved as.\n\nThe `type` parameter in the `base64ImgOptions` is not required. If specified, it will create an image of the given type. If not present, the type will be inferred from the image type section of the base64 image string. If no type portion exists for base64 string, it will default to `png`.\n\n## toBase64\n\n```js\nconst base64Img = require('base64img');\n\n(async () =\u003e {\n\ttry {\n\t\tconst response = await base64Img.toBase64('somepath/sample.png');\t\n\t} catch (error) {\n\t\tconsole.log(error);\n\t\t//=\u003e 'Internal server error ...'\n\t}\n})();\n```\nThe `toBase64` function converts the given image to `base64` string and returns the same. The given imagePath can be any valid path in your filesystem or any image url on the web.\n\n```js\nconst base64Img = require('base64img');\n\n(async () =\u003e {\n\ttry {\n\t\tconst response = await base64Img.toBase64('hhttps://upload.wikimedia.org/wikipedia/en/f/f3/Dilbert-20050910.png');\t\n\t} catch (error) {\n\t\tconsole.log(error);\n\t\t//=\u003e 'Internal server error ...'\n\t}\n})();\n```\n\n## Contributing\n\nBefore opening a pull request please make sure your changes follow the\n[contribution guidelines][1].\n\n[1]: https://github.com/dopecodez/pingman/blob/master/CONTRIBUTING.md\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdopecodez%2Fbase64-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdopecodez%2Fbase64-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdopecodez%2Fbase64-image/lists"}