{"id":20759847,"url":"https://github.com/owsas/image-to-b64","last_synced_at":"2025-07-09T16:05:16.810Z","repository":{"id":91075524,"uuid":"148674457","full_name":"owsas/image-to-b64","owner":"owsas","description":"A module to convert images to b64 that also helps fetching them from the netwrok","archived":false,"fork":false,"pushed_at":"2018-10-01T14:36:14.000Z","size":199,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T16:48:58.702Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/owsas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-09-13T17:38:31.000Z","updated_at":"2021-11-01T03:46:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"ef57989c-11f4-4118-bb05-d4c4b1594674","html_url":"https://github.com/owsas/image-to-b64","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/owsas/image-to-b64","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owsas%2Fimage-to-b64","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owsas%2Fimage-to-b64/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owsas%2Fimage-to-b64/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owsas%2Fimage-to-b64/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/owsas","download_url":"https://codeload.github.com/owsas/image-to-b64/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owsas%2Fimage-to-b64/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264492528,"owners_count":23617032,"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-17T10:08:32.329Z","updated_at":"2025-07-09T16:05:16.750Z","avatar_url":"https://github.com/owsas.png","language":"TypeScript","funding_links":["https://patreon.com/owsas"],"categories":[],"sub_categories":[],"readme":"# @owsas/image-to-b64\n\nA module to convert images to b64 that also helps fetching them from the netwrok\n\n## Installation\n\n```sh\nnpm install --save @owsas/image-to-b64\n```\n\n## Usage\n\n```js\nimport { ImageToB64 } from '@owsas/image-to-b64';\n\nasync function process() {\n  const photoBuffer = await ImageToB64.fetchFromUrl('https://test.com/a.png');\n  const base64 = ImageToB64.toBase64(photoBuffer);\n  console.log(base64); // image/png;base64,AbCDEfGH...\n}\n\nprocess();\n```\n\n## API\n```ts\n\ntype IFileTypeResponse = 'image/png' | 'image/jpg' | 'image/gif';\n\nexport class ImageToB64 {\n  /**\n   * Gets the response from a GET request to an url\n   * @param url\n   */\n  public static fetchFromUrl(url: string): Promise\u003cBuffer\u003e;\n\n  /**\n   * Converts a buffer to base64 only data\n   * @param buffer\n   */\n  public static toBase64OnlyData(buffer: Buffer): string;\n\n  /**\n   * Converts a buffer a to base64 with the type in the beginning\n   * Ex: `image/png;base64,ABCD..`;\n   * @param buffer\n   * @param encodingOrUrl\n   */\n  public static toBase64(buffer: Buffer, encodingOrUrl: string): string;\n\n  /**\n   * Gets the type\n   * @param input\n   */\n  public static getTypeForInput(input: string): IFileTypeResponse | '';\n}\n```\n\n\n## Dev mode\n\nClone this repo, and start adding your code in the `index.ts` file.  \nWhen you are done, write the tests in the `index.test.ts` file. For testing, this repo works with [Jest](https://facebook.github.io/jest/).\n\nOnce you finished, you can publish your module to npm with `npm publish`. This will compile your Typescript code\nand send it to npm.\n\nMake sure to change the name of the package in `package.json`\n\n## Dev Features\n* Testing with Jest\n* Linting out of the box (checks the style of your code), with TSLint\n* Build, prepublish and other scripts to help you to develop\n* Works with Typescript: Static typing for your JS Applications, reducing amount of runtime errors\n* Coverage out of the box, thanks to Jest\n* Uses deterministic module resolving, with Yarn\n\n## Credits\n\nDeveloped by Juan Camilo Guarín Peñaranda,  \nOtherwise SAS, Colombia  \n2017\n\n## License \n\nMIT.\n\n## Support us on Patreon\n[![patreon](./repo/patreon.png)](https://patreon.com/owsas)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowsas%2Fimage-to-b64","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fowsas%2Fimage-to-b64","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowsas%2Fimage-to-b64/lists"}