Skip to main content

Gquote

Using zen.io api this libary is able to generate Quote images
using pillow, Detects quote length and adjust text size accordingly.

example

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

Metadata

Release files for gquote 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gquote 3.0.0
File Size Uploaded Provenance Actions
gquote-3.0.0.tar.gz 221.6 kB Without provenance Details for gquote-3.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gquote 3.0.0
File Interpreter ABI Platform Actions
gquote-3.0.0-py3-none-any.whl Python 3 none any Details for gquote-3.0.0-py3-none-any.whl

Total release size: 440.2 kB

Release files / gquote-3.0.0.tar.gz

Download URL gquote-3.0.0.tar.gz
Size 221.6 kB
Tags Source
SHA-256 checksum
How to use checksums
04b4091f30f4a8155146c07efd47af18a75d6e6357c42819d54835768ce68749
BLAKE2b-256 checksum
How to use checksums
10ef28c9b68c6d85477b39cca683248067dab7214de616d84e517a9653823727
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / gquote-3.0.0-py3-none-any.whl

Download URL gquote-3.0.0-py3-none-any.whl
Size 218.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a6d7e0d8bf19fe97bb3e51c451962ad11852c53d95512b15e6c73b7fe72b1d7
BLAKE2b-256 checksum
How to use checksums
45616d1d1e2a35e9c8ab694a3084ca85b35db5291ebeb1a5ed63e7506e7b484b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Security for gquote 3.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page