# Gquote
Using zen.io api this libary is able to generate Quote images
using pillow, Detects quote length and adjust text size accordingly.
<img src="https://raw.githubusercontent.com/Justxd22/Quote-to-PNG_XD/main/todayquote.png" width="360" height="640" alt="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"`
```py
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
```py
from gquote import gquote
image = gquote(background="/home/xd/wqfdir.jpg", color="#ff00dd").run()
```
Or
```py
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
```py
from gquote import gquote
image = gquote(shape="box").run() # outputs 1080x1350
```
Or
```py
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 <a href="https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html">pillow supported image formats for more</a>
```py
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
```py
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.
```py
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 <a href="https://pillow.readthedocs.io/en/stable/reference/ImageFont.html">pillow docs for more supported formats,</a>
You have to pass list of two fonts to be used,
one for the quote, other for the author text.
```py
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: <a href="https://xd22.me">xd22.me</a>
Raw data
{
"_id": null,
"home_page": "https://github.com/justxd22/gquote",
"name": "gquote",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "quotes,png,images,pillow,generate",
"author": "Justxd22",
"author_email": "xdjust18@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/10/ef/28c9b68c6d85477b39cca683248067dab7214de616d84e517a9653823727/gquote-3.0.0.tar.gz",
"platform": null,
"description": "\n# Gquote\n\nUsing zen.io api this libary is able to generate Quote images \nusing pillow, Detects quote length and adjust text size accordingly. \n\n<img src=\"https://raw.githubusercontent.com/Justxd22/Quote-to-PNG_XD/main/todayquote.png\" width=\"360\" height=\"640\" alt=\"example\"/>\n\n## Install\n\nUse pip to install `pip install gquote` \n\nDepends on: \n - pillow\n - textwrap\n - requests\n\nInstall using pip: `pip install pillow textwrap requests` \n\n## Usage\n\nThis libary was designed to be as customizable as possible \n\n### Use proxy \n\npass requests proxy format `\"protocol\" : \"address\"` \n```py\nfrom gquote import gquote\n\nimage = gquote(proxy={\"https\":\"127.0.0.1:8080\"}).run()\n```\n\n### Custom Background with Text Shadow\n\nYou can use custom background, Optionally pass Color from your background \nIt will be used as text shadow, So text can be easily read, \nAlso it will be used to calc background Intensty, \nResults in Text color From a contrast equation \nNote that Custom Backround Sizes allowed: 1080x1920, 1080x1350 \nColor Format allowed: HEX, RGB \n```py\nfrom gquote import gquote\n\nimage = gquote(background=\"/home/xd/wqfdir.jpg\", color=\"#ff00dd\").run()\n```\nOr \n```py\nfrom urllib.request import urlretrieve\nfrom gquote import gquote\n\nbackground = urlretrieve('https://i.imgur.com/7pfR6Ua.png')[0]\nimage = gquote(background=background, color=(0,0,0)).run()\n```\n\n### Change image shape/size\n\nYou can choose between two shapes portrait, or box size \n```py\nfrom gquote import gquote\n\nimage = gquote(shape=\"box\").run() # outputs 1080x1350\n```\nOr \n```py\nfrom gquote import gquote\n\nimage = gquote(shape=\"portrait\").run() # outputs 1080x1920\n```\n\n### Change output path or format\n\nPass output format as name + .png, .jpg, .jpeg \nCheck <a href=\"https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html\">pillow supported image formats for more</a> \n```py\nfrom gquote import gquote\n\nimage = gquote(output=\"/home/xd/cloud/quote.jpg\").run()\n```\n\n### Export to Memory\n\nFor faster output or Saving disk IO usage, \nyou can save to Memory as BytesIO object \nOptionally you can choose output format \nby passing format var, default format is PNG, \nLater you can save image to disk by `getbuffer()`, \nMake sure you use same format of the output \n```py\nfrom gquote import gquote\n\nimage = gquote(output=False, format=\"jpg\").run()\n\nwith open('quote.jpg', 'wb') as f: # .jpg same format\n f.write(image.getbuffer())\n f.close()\n```\n\n### Use diffrent API\n\nYou can change the api to your choice, \nalso you can pass headers if api requires Auth. \n```py\nfrom gquote import gquote\n\nimage = gquote(base=\"https://yourapiofchoice.io/api/quote\", headers={'Content-Type': 'application/json', 'Accept': '*/*', 'Origin': 'https://zenquotes.io', 'User-Agent':....}).run()\n```\n\n### Custom Fonts\n\nYou can pass fonts path of your choice, \nttf and otf formats are supported, \nCheck <a href=\"https://pillow.readthedocs.io/en/stable/reference/ImageFont.html\">pillow docs for more supported formats,</a> \nYou have to pass list of two fonts to be used, \none for the quote, other for the author text. \n```py\nfrom gquote import gquote\n\nimage = gquote(fonts=[\"/home/xd/ubutu-font.ttf\", \"/home/xd/ubutu-font-italic.ttf\"]).run()\n```\n\n## Credits\n\nBig thanks to zenquotes.io for their amazing freeware api \n\n## Donation\n\nYou can support my work by donating to the following address, \n - XMR - `433CbZXrdTBQzESkZReqQp1TKmj7MfUBXbc8FkG1jpVTBFxY9MCk1RXPWSG6CnCbqW7eiMTEGFgbHXj3rx3PxZadPgFD3DX`\nTHANKS KIND SOUL! \n\n\nFind me: <a href=\"https://xd22.me\">xd22.me</a>\n",
"bugtrack_url": null,
"license": "GPLV3",
"summary": "Generate Beautiful quote images",
"version": "3.0.0",
"split_keywords": [
"quotes",
"png",
"images",
"pillow",
"generate"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "740639f62939cd3129c967313383ffb5",
"sha256": "3a6d7e0d8bf19fe97bb3e51c451962ad11852c53d95512b15e6c73b7fe72b1d7"
},
"downloads": -1,
"filename": "gquote-3.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "740639f62939cd3129c967313383ffb5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 218572,
"upload_time": "2022-12-03T14:40:03",
"upload_time_iso_8601": "2022-12-03T14:40:03.746967Z",
"url": "https://files.pythonhosted.org/packages/45/61/6d1d1e2a35e9c8ab694a3084ca85b35db5291ebeb1a5ed63e7506e7b484b/gquote-3.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "d322b7e2182114de5deb2628f9f24a1c",
"sha256": "04b4091f30f4a8155146c07efd47af18a75d6e6357c42819d54835768ce68749"
},
"downloads": -1,
"filename": "gquote-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "d322b7e2182114de5deb2628f9f24a1c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 221603,
"upload_time": "2022-12-03T14:40:08",
"upload_time_iso_8601": "2022-12-03T14:40:08.314367Z",
"url": "https://files.pythonhosted.org/packages/10/ef/28c9b68c6d85477b39cca683248067dab7214de616d84e517a9653823727/gquote-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-03 14:40:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "justxd22",
"github_project": "gquote",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "gquote"
}