{"id":17104620,"url":"https://github.com/imyelo/todataurl","last_synced_at":"2025-10-28T06:02:34.444Z","repository":{"id":12486854,"uuid":"15156225","full_name":"imyelo/toDataURL","owner":"imyelo","description":"url or \u003cimg\u003e element to DataURL","archived":false,"fork":false,"pushed_at":"2015-09-02T12:10:05.000Z","size":336,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T01:12:28.265Z","etag":null,"topics":["dataurl","img","javascript"],"latest_commit_sha":null,"homepage":"","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/imyelo.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}},"created_at":"2013-12-13T06:11:21.000Z","updated_at":"2021-07-26T09:52:36.000Z","dependencies_parsed_at":"2022-09-23T07:40:35.828Z","dependency_job_id":null,"html_url":"https://github.com/imyelo/toDataURL","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imyelo%2FtoDataURL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imyelo%2FtoDataURL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imyelo%2FtoDataURL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imyelo%2FtoDataURL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imyelo","download_url":"https://codeload.github.com/imyelo/toDataURL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650754,"owners_count":21139681,"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":["dataurl","img","javascript"],"created_at":"2024-10-14T15:37:31.093Z","updated_at":"2025-10-28T06:02:29.419Z","avatar_url":"https://github.com/imyelo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"toDataURL\n=========\n[![npm version](https://badge.fury.io/js/to-data-url.svg)](http://badge.fury.io/js/to-data-url)\n[![Build Status](https://travis-ci.org/imyelo/toDataURL.png?branch=master)](https://travis-ci.org/imyelo/toDataURL)\n[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)\n[![Codeship](https://www.codeship.io/projects/6fdea9f0-5b0b-0131-17de-32bbd7e9b736/status)](https://www.codeship.io/projects/11860)\n\nurl or \u0026lt;img\u003e element to DataURL\n\n## Install\n```\nnpm install --save to-data-url\n```\n\n\n# Usage\n```javascript\ndefine(['toDataURL'], function (toDataURL) {\n    var element = document.getElementByTagName('img')[0];\n    var src = 'https://avatars0.githubusercontent.com/u/7076521?v=2\u0026s=84';\n\n    /* you can get the dataUrl from an element (not a url) synchronously, */\n    console.log(toDataURL(element));\n    // \u003e data:image/png;base64,iVBORw0KGgo...\n\n    /* but that sync method may cause some issues, so you can also make it by an async way. */\n    toDataURL(element, {\n        callback: function (err, data) {\n            if (!err) console.log(data);\n            // \u003e data:image/png;base64,iVBORw0KGgo...\n        }\n    });\n\n    /* or get the dataUrl from a url asynchronously */\n    toDataURL(src, {\n        callback: function (err, data) {\n            if (!err) console.log(data);\n            // \u003e data:image/png;base64,iVBORw0KGgo...\n        }\n    });\n\n    /* and define the width and height */\n    toDataURL(src, {\n        width: 120,\n        height: 120,\n        callback: function (err, data) {\n            if (!err) console.log(data);\n            // \u003e data:image/png;base64,iVBORw0KGgo...\n        }\n    });\n\n    /* maybe you just want the base64 data */\n    toDataURL(src, {\n        purify: true,\n        callback: function (err, data) {\n            if (!err) console.log(data);\n            // \u003e iVBORw0KGgo...\n        }\n    });\n});\n```\n\n## API\n### toDataURL(image, options)\n#### params\n- `image` {Image|String}\n- `options` {Object}\n\n#### return\n- `data` {null|String}\n\n#### options\n- `width` {Number=0}\n- `height` {Number=0}\n- `purify` {Boolean=false}\n- `callback` {Function}\n\n#### callback\n- `err` {Error}\n- `data` {String}\n\n## Release History\n- 0.1.0\n    - support ``toDataURL(elem, [width], [height])``\n- 1.0.0\n    - support ``toDataURL(elem, {[callback], [width], [height], [purify]})``\n    - support ``toDataURL(src, {callback, [width], [height], [purify]})``\n    - deprecate ``toDataURL(elem, width, height)``\n- 1.0.1\n    - friendly expection message\n    - add duojs compiler\n\n## License\nthe MIT License\n\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/imyelo/todataurl/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimyelo%2Ftodataurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimyelo%2Ftodataurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimyelo%2Ftodataurl/lists"}