Giter Club home page Giter Club logo

b64's Introduction

b64!

Python 3.7.1

convert offline/online data to base64 clean, fast and easy

what b64 do for you?

  • clean, fast and easy
  • convert data (image, video, text) to base64 from URL or local or b'string'
  • convert base64 to data (image, video, text)
  • auto-detect source type all you have to do is inserting the source
  • support proxies, custom success code
  • convert data to html(base64) tags, and data_uri

install

You can either install from pypi or the source code

  1. Using pip
pip install b64
  1. from the source code
git clone https://github.com/n0x1s/b64
cd b64
python setup.py install

How to use

1) Converting local/remote images/text ... to base64 and the opposite

Let us suppose you have a group of data that you want to convert to base64 or the opposite

>>> from b64 import B64
### some examples ####
>>> online_image = 'https://avatars3.githubusercontent.com/u/1'
>>> local_image = 'test.jpg'
>>> string = 'hello'.encode()
>>> online_base64 = 'https://pastebin.com/raw/mYPrvzDz'
>>> local_base64 = 'example.txt'
>>> b64_string = b'aGVsbG8='
  1. converting online data
>>> B64(online_image).data # converting image to base64
> b'iVBORw0KGgoAAAANSUhEUgAAAcwAAAHMCAYAAABY25iGA...'
>>> B64('https://pastebin.com/raw/mYPrvzDz', to='string', codes=[200, 201]).data # you can set the success http codes or use proxies
> b'Hello'
  1. converting local data
>>> B64(local_image).data # converting image to base64
> b'iVBORw0KGgoAAAANSUhEUgAAAcwAAAHMCAYAAABY25iGA...'
>>> B64('example.txt', to='string').data # converting local base64 string to bytes
> b'Hello'

2) convert videos/images/css/js ... to html tag

>>> from b64 import Tag64
>>> t = Tag64('https://avatars3.githubusercontent.com/u/1', 'img')
>>> t.html_tag
> '<img src="data:;base64,/9j/4AAQSkZJRgABAQAAAQA...'
>>> t.data_uri
> b'iVBORw0KGgoAAAANSUhEUgAAAcwAAAHMCAYAAABY25iGA...'

Todo

I will try to maintain this respiratory and update or add new things to it you are welcome to contribute ☺️

And, as always have a beautiful day!

b64's People

Contributors

n0x1s avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

chaieb-adel

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.