Verified Commit d037e3b1 authored by Torsten Grote's avatar Torsten Grote
Browse files

Add script for automatically cropping screenshots

parent 95cbee08
#!/usr/bin/env python3
import os
from PIL import Image
IMAGE_PATH = "content/assets/img"
POSTFIX = '-cropped'
def main():
crop('introduction-5.png', 77, 47)
crop('manage-rss-feeds-2.png', 35)
crop('manual_dark_theme_settings.png', 45)
crop('manual_dark_theme_nav_drawer.png', 64)
def crop(file_name, bottom, top_offset=0, only_show=False):
file_path = os.path.join(IMAGE_PATH, file_name)
if not os.path.isfile(file_path):
print("Warning: File not found %s" % file_path)
with as image:
left_c = 0
top_c = image.size[1] * top_offset / 100
right_c = image.size[0]
bottom_c = image.size[1] * bottom / 100
image_cropped = image.crop((left_c, top_c, right_c, bottom_c))
if only_show:
file_path_cropped = get_new_filename(file_path)
def get_new_filename(file_path):
name, ext = os.path.splitext(file_path)
return name + POSTFIX + ext
if __name__ == "__main__":
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment