Skip to main content

ShareImage

A Python Library to Generate Dynamic Share Images. Powered by Cloudinary

Installation

Windows

pip install ShareImage

Linux / macOS

python3 -m pip install ShareImage

Usage

ShareImage Can be easily integrated in any Python Project. For example, in Flask:

from flask import Flask, render_template
from ShareImage import ShareImage

app = Flask(__name__)

@app.route('/')
def index():
    image = ShareImage(
        title="Home",
        cloudName="CLOUDINARY_CLOUD_NAME",
        imagePublicId="CLOUDINARY_IMAGE_ID"
    )
    return render_template('index.html', image=image)

@app.route('/posts/<string:slug>')
def posts(slug):
    image = ShareImage(
        title=bySlug.get(slug)['title'],
        cloudName="CLOUDINARY_CLOUD_NAME",
        imagePublicId="CLOUDINARY_IMAGE_ID"
    )
    return render_template('index.html', image=image)

if __name__=="__main__":
    app.run()

Now, you can use the image variable in any img Tag or og:image/twitter:image/image Meta Tags! Note: CLOUDINARY_CLOUD_NAME and CLOUDINARY_IMAGE_ID are respectedly Your Cloudinary Cloud Name and Image Public Id (Including Folder Name) & the bySlug is a Special Variable to find specific posts in a Array of Dictionaries by Slug and it can be achieved by the following Code:

def build_dict(seq, key):
    return dict((d[key], dict(d, index=index)) for (index, d) in enumerate(seq))

bySlug = build_dict(ARRAY_OF_POSTS, key="KEY_OF_SLUG")

# Usage: bySlug(SLUG_OF_POST)['KEY_TO_FIND']

Metadata

Release files for PIPWeb 1.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 PIPWeb 1.0.0
File Size Uploaded
PIPWeb-1.0.0.tar.gz 4.0 kB Details

Built distribution (wheel)

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

Total release size: 8.0 kB

Release files / PIPWeb-1.0.0.tar.gz

Download URL PIPWeb-1.0.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c156618c962a5bc08250ede229be27d96cb512193ea723b3ee9ac87fc7276815
BLAKE2b-256 checksum
How to use checksums
1b8ded3ae4e6ad53de5dbcba9ef4c56a32a1100ab8c55a32e86b870732834d73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Release files / PIPWeb-1.0.0-py3-none-any.whl

Download URL PIPWeb-1.0.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d232aa3eb8f609624bdd2aa5157b89aadff85f8a9d038b51dc443b2ad7c3156
BLAKE2b-256 checksum
How to use checksums
2df4c6b1fc42505879b59d9d816ccb3bc7350e791abfffd93391224f89f6cd3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

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