Skip to main content

A Python RFC2397 ("data url") implementation

Project description

Author:

Jacob Oscarson

Contact email:

jacob@plexical.com

Quick implementation of RFC2397 in Python, MIT Licenced. RFC2397 is also known as the ‘data url’ format used to embed image data directly into CSS stylesheets among other things.

The rationale behind this package is described in this blogpost.

Requirements

Python 2.6 and 2.7, not tested on Python 3+ (yet).

Installation

The latest version can be found on PyPI. The recommended way to install is via pip:

$ pip install rfc2397

An executable named rfc2397 is then placed in the python environment that pip installs to.

As an alternate method, it’s also possible to copy the rfc2397.py file to any location and run the script stand-alone.

Usage

Just give rfc2397 a path to an image file. rfc2397 uses Python’s mimetypes module to determine what MIME-type a file has (N.B: the program won’t stop you from encoding something too large/an unsupported mime-type).

$ rfc2397 dot.png # <- your image path data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVQImWP4o8oAAANCASIYayeeAAAAAElFTkSuQmCC

Changes

1.0b2 (2012-01-03)

  • Uses mimetypes module instead of primitive ad-hoc file name extension guessing.

  • rfc2397 is now a single-file module, simplifies package and makes it possible to just copy the rfc2397.py file to an arbitrary location as an alternate installation method.

  • Better QA by using tox.

1.0b1 (2011-06-16)

Concept and initial coding.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rfc2397-1.0b2.tar.gz (2.9 kB view details)

Uploaded Source

File details

Details for the file rfc2397-1.0b2.tar.gz.

File metadata

  • Download URL: rfc2397-1.0b2.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rfc2397-1.0b2.tar.gz
Algorithm Hash digest
SHA256 e321ae83b6c7d0a9ecd13aafa7cad75c5d30e3d51e325a4c22ee1a283ad5edc4
MD5 51e52231c417a18323446660d721c6e4
BLAKE2b-256 27e77ab5fb4bd190fcdcae2573c5c7d566085530dee6f5c9ad03eb13fc07e080

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page