{"id":20119160,"url":"https://github.com/harrystevens/ba64","last_synced_at":"2025-09-13T15:55:41.464Z","repository":{"id":66335684,"uuid":"106898749","full_name":"HarryStevens/ba64","owner":"HarryStevens","description":"A tiny npm module for saving Base64 encoded images that are part of data URLs to your file system.","archived":false,"fork":false,"pushed_at":"2023-03-01T09:14:01.000Z","size":60,"stargazers_count":10,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T05:45:05.126Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/ba64","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/HarryStevens.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":"2017-10-14T04:43:35.000Z","updated_at":"2020-11-15T06:31:16.000Z","dependencies_parsed_at":"2023-04-01T11:36:44.431Z","dependency_job_id":null,"html_url":"https://github.com/HarryStevens/ba64","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryStevens%2Fba64","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryStevens%2Fba64/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryStevens%2Fba64/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarryStevens%2Fba64/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HarryStevens","download_url":"https://codeload.github.com/HarryStevens/ba64/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252703453,"owners_count":21790887,"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-11-13T19:14:38.808Z","updated_at":"2025-05-06T14:32:12.806Z","avatar_url":"https://github.com/HarryStevens.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ba64\n[![Build Status](https://travis-ci.org/HarryStevens/ba64.svg?branch=master)](https://travis-ci.org/HarryStevens/ba64) [![Coverage Status](https://coveralls.io/repos/github/HarryStevens/ba64/badge.svg?branch=master)](https://coveralls.io/github/HarryStevens/ba64?branch=master)\n\nA tiny npm module for saving Base64 encoded images that are part of [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) to your file system. This is useful for saving images that have been uploaded to the browser via [`FileReader.readAsDataUrl()`](https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL).\n\n* [Installation](#installation)\n* [Example](#example)\n* [API](#api)\n\n## \u003ca name=\"installation\" href=\"#installation\"\u003eInstallation\u003c/a\u003e\n\n```bash\nnpm i ba64 -S\n```\n\n## \u003ca name=\"example\" href=\"#example\"\u003eExample\u003c/a\u003e\n\n```js\nvar ba64 = require(\"ba64\"),\n  data_url = \"data:image/jpeg;base64,[Base64 encoded image goes here]\";\n\n// Save the image synchronously.\nba64.writeImageSync(\"myimage\", data_url); // Saves myimage.jpeg.\n\n// Or save the image asynchronously.\nba64.writeImage(\"myimage\", data_url, function(err){\n  if (err) throw err;\n\n  console.log(\"Image saved successfully\");\n\n  // do stuff\n});\n```\n\n## \u003ca name=\"api\" href=\"#api\"\u003eAPI\u003c/a\u003e\n\n\u003ca name=\"writeImage\" href=\"#writeImage\"\u003e#\u003c/a\u003e ba64.**writeImage**(*path/to/file_name*, *data_url*, *callback*)\n\nAsynchronously saves the Base64 encoded image to the file system. `file_name` should not include the file extension; ba64 will do that for you.\n\n\u003ca name=\"writeImageSync\" href=\"#writeImageSync\"\u003e#\u003c/a\u003e ba64.**writeImageSync**(*path/to/file_name*, *data_url*)\n\nSynchronously saves the Base64 encoded image to the file system. `file_name` should not include the file extension; ba64 will do that for you.\n\n### Helper functions\n\n\u003ca name=\"getExt\" href=\"#getExt\"\u003e#\u003c/a\u003e ba64.**getExt**(*data_url*)\n\nReturns the file extension of the Base64 encoded image.\n\n\u003ca name=\"getBa64Img\" href=\"#getBa64Img\"\u003e#\u003c/a\u003e ba64.**getBa64Img**(*data_url*)\n\nReturns the Base64 encoded image without the `data:` scheme prefix.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharrystevens%2Fba64","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharrystevens%2Fba64","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharrystevens%2Fba64/lists"}