Generate Beautiful quote images
Project description
Gquote
Using zen.io api this libary is able to generate Quote images
using pillow, Detects quote length and adjust text size accordingly.
Install
Use pip to install pip install gquote
Depends on:
- pillow
- textwrap
- requests
Install using pip: pip install pillow textwrap requests
Usage
This libary was designed to be as customizable as possible
Use proxy
pass requests proxy format "protocol" : "address"
from gquote import gquote
image = gquote(proxy={"https":"127.0.0.1:8080"}).run()
Custom Background with Text Shadow
You can use custom background, Optionally pass Color from your background
It will be used as text shadow, So text can be easily read,
Also it will be used to calc background Intensty,
Results in Text color From a contrast equation
Note that Custom Backround Sizes allowed: 1080x1920, 1080x1350
Color Format allowed: HEX, RGB
from gquote import gquote
image = gquote(background="/home/xd/wqfdir.jpg", color="#ff00dd").run()
Or
from urllib.request import urlretrieve
from gquote import gquote
background = urlretrieve('https://i.imgur.com/7pfR6Ua.png')[0]
image = gquote(background=background, color=(0,0,0)).run()
Change image shape/size
You can choose between two shapes portrait, or box size
from gquote import gquote
image = gquote(shape="box").run() # outputs 1080x1350
Or
from gquote import gquote
image = gquote(shape="portrait").run() # outputs 1080x1920
Change output path or format
Pass output format as name + .png, .jpg, .jpeg
Check pillow supported image formats for more
from gquote import gquote
image = gquote(output="/home/xd/cloud/quote.jpg").run()
Export to Memory
For faster output or Saving disk IO usage,
you can save to Memory as BytesIO object
Optionally you can choose output format
by passing format var, default format is PNG,
Later you can save image to disk by getbuffer()
,
Make sure you use same format of the output
from gquote import gquote
image = gquote(output=False, format="jpg").run()
with open('quote.jpg', 'wb') as f: # .jpg same format
f.write(image.getbuffer())
f.close()
Use diffrent API
You can change the api to your choice,
also you can pass headers if api requires Auth.
from gquote import gquote
image = gquote(base="https://yourapiofchoice.io/api/quote", headers={'Content-Type': 'application/json', 'Accept': '*/*', 'Origin': 'https://zenquotes.io', 'User-Agent':....}).run()
Custom Fonts
You can pass fonts path of your choice,
ttf and otf formats are supported,
Check pillow docs for more supported formats,
You have to pass list of two fonts to be used,
one for the quote, other for the author text.
from gquote import gquote
image = gquote(fonts=["/home/xd/ubutu-font.ttf", "/home/xd/ubutu-font-italic.ttf"]).run()
Credits
Big thanks to zenquotes.io for their amazing freeware api
Donation
You can support my work by donating to the following address,
- XMR -
433CbZXrdTBQzESkZReqQp1TKmj7MfUBXbc8FkG1jpVTBFxY9MCk1RXPWSG6CnCbqW7eiMTEGFgbHXj3rx3PxZadPgFD3DX
THANKS KIND SOUL!
Find me: xd22.me
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
Built Distribution
File details
Details for the file gquote-3.0.0.tar.gz
.
File metadata
- Download URL: gquote-3.0.0.tar.gz
- Upload date:
- Size: 221.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04b4091f30f4a8155146c07efd47af18a75d6e6357c42819d54835768ce68749 |
|
MD5 | d322b7e2182114de5deb2628f9f24a1c |
|
BLAKE2b-256 | 10ef28c9b68c6d85477b39cca683248067dab7214de616d84e517a9653823727 |
File details
Details for the file gquote-3.0.0-py3-none-any.whl
.
File metadata
- Download URL: gquote-3.0.0-py3-none-any.whl
- Upload date:
- Size: 218.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a6d7e0d8bf19fe97bb3e51c451962ad11852c53d95512b15e6c73b7fe72b1d7 |
|
MD5 | 740639f62939cd3129c967313383ffb5 |
|
BLAKE2b-256 | 45616d1d1e2a35e9c8ab694a3084ca85b35db5291ebeb1a5ed63e7506e7b484b |