Skip to main content

Python package to help create screenshot to upload on stores

Project description

ScreenshotFormat

Python package to help create screenshot to upload on stores

Instantiate the helper with your screenshot, and the desired store image size

from ScreenshotFormat import ScreenshotFormat, StoreSizeName, BackgroundType, Position

# 1. your screenshot
# - pass the path of your screenshot with "screenshot_path"
# - Or directly a PIL image with "screenshot_img"

2. screenshot size
# - By using the Enum StoreSizeName in "store_size_name" param
# - Or by passing a tuple (with, height) in "store_size"
helper = ScreenshotFormat(
                screenshot_path=PATH_SCREENSHOT, 
                store_size_name=StoreSizeName.iphone_6_5)

Retrieve sizes

# get your screenshot size with :
width, height = helper.screenshot_size

# get your store size with :
width, height = helper.store_size

Crop your screenshot

helper.crop_screenshot(left=None, top=100, right=None, bottom=None)

Resize your screenshot

A ratio will multply width & height to keep

helper.resize_screenshot(zoom_ratio=1.3)

Pass the desired size

helper.resize_screenshot(size=(1080, 1920))

Create a background

the image created will have the size of the store you pass the constructor. All the background types are inside the Enum "BackgroundType":

  • plain : A background with only one color
  • vertical_gradient : A gradient from top to bottom
  • horizontal_gradient : A gradient from left to right
  • diagonal_gradient_right : A gradient from the top right corner to the bottom left corner
  • diagonal_gradient_left : A gradient from the top left corner to the bottom right corner

You can pass as many color as you want in the "color_palette" argument

background = helper.create_background(type_=BackgroundType.diagonal_gradient_right, color_palette=[
    (255, 0, 0),
    (255, 255, 0),
    (255, 255, 255),
])

Adding text

text_position = (Position.center, 150)
text = "My Caption"
background = helper.add_text_with_halo(background,
                                       text=text,
                                       position=text_position,
                                       color=(0, 0, 0),
                                       halo_col=(255, 255, 255),
                                       font_path=PATH_TO_YOUR_FONT,
                                       font_size=120)

Pasting the screenshot on the background

position = (Position.center, helper.store_height - helper.screenshot_height - 100)
final_image = helper.apply_screenshot_on_background(background, position)

Save image

ScreenshotFormat.save(img=final_image, path=OUTPUT_PATH, file_name="MyScreenshot.jpg")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

ScreenshotFormat-1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file ScreenshotFormat-1-py3-none-any.whl.

File metadata

  • Download URL: ScreenshotFormat-1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.4

File hashes

Hashes for ScreenshotFormat-1-py3-none-any.whl
Algorithm Hash digest
SHA256 b12d6552550ff6e0c973caf942025f4e69094a0cd60ac570f5f926456a0e952e
MD5 00aa550a4baf4a272a1c867e8113a1d5
BLAKE2b-256 73c77deeb5e002c0e8fcbfa629b203981b3b3aeff924299d5bf95630793aef81

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page