{"id":16948621,"url":"https://github.com/fcurella/python-datauri","last_synced_at":"2025-04-13T08:25:08.007Z","repository":{"id":21964813,"uuid":"94564800","full_name":"fcurella/python-datauri","owner":"fcurella","description":"Data URI manipulation made easy.","archived":false,"fork":false,"pushed_at":"2025-01-03T16:42:46.000Z","size":182,"stargazers_count":55,"open_issues_count":0,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T08:24:56.700Z","etag":null,"topics":["data-uri","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fcurella.png","metadata":{"files":{"readme":"README.rst","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-06-16T17:02:18.000Z","updated_at":"2025-04-08T08:10:42.000Z","dependencies_parsed_at":"2024-06-18T19:58:24.564Z","dependency_job_id":"9ebf4f24-f5ca-4c75-9674-57ecba5c72c9","html_url":"https://github.com/fcurella/python-datauri","commit_stats":{"total_commits":118,"total_committers":6,"mean_commits":"19.666666666666668","dds":"0.11864406779661019","last_synced_commit":"ffc4503522d2454b419117bb1af326dcb4f80dcf"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcurella%2Fpython-datauri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcurella%2Fpython-datauri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcurella%2Fpython-datauri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcurella%2Fpython-datauri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fcurella","download_url":"https://codeload.github.com/fcurella/python-datauri/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248682173,"owners_count":21144806,"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":["data-uri","python"],"created_at":"2024-10-13T21:51:41.062Z","updated_at":"2025-04-13T08:25:07.972Z","avatar_url":"https://github.com/fcurella.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"DataURI\n=======\n\n.. image:: https://github.com/fcurella/python-datauri/workflows/Python%20Tests/badge.svg\n    :target: https://github.com/fcurella/python-datauri/actions?query=workflow%3A%22Python+Tests%22\n    :alt: Build status of the master branch on Mac/Linux\n\n.. image:: https://coveralls.io/repos/github/fcurella/python-datauri/badge.svg?branch=master\n    :target: https://coveralls.io/github/fcurella/python-datauri?branch=master\n\nData URI manipulation made easy.\n\nThis isn't very robust, and will reject a number of valid data URIs. However, it meets the most useful case: a mimetype, a charset, and the base64 flag.\n\n\nInstallation\n------------\n\n.. code-block:: bash\n\n  $ pip install python-datauri\n\n\nParsing\n-------\n\n.. code-block:: python\n\n  \u003e\u003e\u003e from datauri import DataURI\n  \u003e\u003e\u003e uri = DataURI('data:text/plain;charset=utf-8;base64,VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2cu')\n  \u003e\u003e\u003e uri.mimetype\n  'text/plain'\n  \u003e\u003e\u003e uri.charset\n  'utf-8'\n  \u003e\u003e\u003e uri.is_base64\n  True\n  \u003e\u003e\u003e uri.data\n  b'The quick brown fox jumped over the lazy dog.'\n\nNote that ``DataURI.data`` will always return bytes.\nUse ``DataURI.text`` to get a string.\n\nCreating from a string\n----------------------\n\n.. code-block:: python\n\n  \u003e\u003e\u003e from datauri import DataURI\n  \u003e\u003e\u003e made = DataURI.make('text/plain', charset='us-ascii', base64=True, data='This is a message.')\n  \u003e\u003e\u003e made\n  DataURI('data:text/plain;charset=us-ascii;base64,VGhpcyBpcyBhIG1lc3NhZ2Uu')\n  \u003e\u003e\u003e made.data\n  b'This is a message.'\n\nCreating from a file\n--------------------\n\nThis is really just a convenience method.\n\n.. code-block:: python\n\n  \u003e\u003e\u003e from datauri import DataURI\n  \u003e\u003e\u003e png_uri = DataURI.from_file('somefile.png')\n  \u003e\u003e\u003e png_uri.mimetype\n  'image/png'\n  \u003e\u003e\u003e png_uri.data\n  b'\\x89PNG\\r\\n...'\n\n\nSerializing\n-----------\n\n`DataURI` is a subclass of `str`, so you can just use `str()` to print it out:\n\n.. code-block:: python\n\n  \u003e\u003e\u003e from datauri import DataURI\n  \u003e\u003e\u003e png_uri = DataURI.from_file('somefile.png')\n  \u003e\u003e\u003e str(png_uri)\n  'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIA...'\n \nPydantic Support\n----------------\n\nYou can use `DataURI` as a type for `Pydantic`:\n\n.. code-block:: python\n\n  from datauri import DataURI\n  from pydantic import BaseModel\n\n\n  class ProfilePicture(BaseModel):\n    image_data: DataURI\n\nLicense\n-------\n\nThis code is released under the `Unlicense \u003chttp://unlicense.org/\u003e`_.\n\nCredits\n-------\n\nThis is a repackaging of `this Gist \u003chttps://gist.github.com/zacharyvoase/5538178\u003e`_\noriginally written by `Zachary Voase \u003chttps://github.com/zacharyvoase\u003e`_.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcurella%2Fpython-datauri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffcurella%2Fpython-datauri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcurella%2Fpython-datauri/lists"}