From ae8a04176b47ade44fd7b6b7a05411f01f311c64 Mon Sep 17 00:00:00 2001 From: oloturia Date: Thu, 17 Dec 2020 02:48:30 +0100 Subject: [PATCH] added x-y and panel dimensions to config file --- README.md | 3 +++ config.json | 3 +++ randstrip.py | 11 +++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0115a3f..02f93bd 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,9 @@ Configuration file is a JSON with this tree: filename: the default filename used by function createStrip, if not specified (not used in any of the scripts, at the moment) imagesLocation: the folder where the different panels are stored csvLocation: the folder where the csv are stored + xSize: width of the final image + ySize: height of the final image + panelLength: length of the single panel (roughly panelLength * number-of-panels should be = xSize) font: the font used "application":{ special instruction for applications, like "twitter", "mastodon", "telegram" "token" token location diff --git a/config.json b/config.json index e871e2a..3110d83 100644 --- a/config.json +++ b/config.json @@ -7,6 +7,9 @@ "imagesLocation": "./oloturia", "csvLocation": "./oloturia", "font": "./ubuntu.ttf", + "xSize":2400, + "ySize":500, + "panelLength":600, "twitter": { "token": "./twitter_token", "filename": "/twitter.png" diff --git a/randstrip.py b/randstrip.py index 9ad530a..daa07d0 100755 --- a/randstrip.py +++ b/randstrip.py @@ -112,11 +112,11 @@ def writeStrip(story,fontSize,config): strip.append(vign) except FileNotFoundError: pass - image = Image.new('RGBA',(2400,500)) + image = Image.new('RGBA',(config["xSize"],config["ySize"])) xshift=0 for vign in strip: image.paste(vign,(xshift,0)) - xshift += 600 + xshift += config["panelLength"] return image def createStrip(config,specialPlatform="",fontSize=22): @@ -154,12 +154,15 @@ def readConfig(profile=False,platform=False): imagesLocation = checkLocal(config[profile]["imagesLocation"]) csvLocation = checkLocal(config[profile]["csvLocation"]) font = checkLocal(config[profile]["font"]) + xSize = config[profile]["xSize"] + ySize = config[profile]["ySize"] + panelLength = config[profile]["panelLength"] if platform: token = checkLocal(config[profile][platform]["token"]) filename = checkLocal(config[profile][platform]["filename"]) - return {"saveLocation":saveLocation,"imagesLocation":imagesLocation,"csvLocation":csvLocation,"font":font,"token":token,"filename":filename} + return {"saveLocation":saveLocation,"imagesLocation":imagesLocation,"csvLocation":csvLocation,"font":font,"token":token,"filename":filename,"xSize":xSize,"ySize":ySize,"panelLength":panelLength} filename = config[profile]["filename"] - return {"saveLocation":saveLocation,"imagesLocation":imagesLocation,"csvLocation":csvLocation,"font":font,"filename":filename} + return {"saveLocation":saveLocation,"imagesLocation":imagesLocation,"csvLocation":csvLocation,"font":font,"filename":filename,"xSize":xSize,"ySize":ySize,"panelLength":panelLength} def checkLocal(directory): """Checks if it's a relative or absolute path"""