1
0
Fork 0
mirror of https://gitlab.com/oloturia/fumcaso.git synced 2025-01-08 22:47:17 +01:00

added font size in config file

This commit is contained in:
oloturia 2021-03-13 18:57:12 +01:00
parent 29d441453c
commit e0ddda92c3
3 changed files with 23 additions and 7 deletions

14
.gitignore vendored Normal file
View file

@ -0,0 +1,14 @@
telegram_token
twitter_token
mastodon_token
telegram.png
mastodon.png
twitter.png
android.png
__pycache__/*
oloturia_credentials.secret
history/*
bin/*
temp/*
show.html
*.pyc

View file

@ -11,6 +11,7 @@
"csvSubs": "subs.csv", "csvSubs": "subs.csv",
"csvObj": "obj.csv", "csvObj": "obj.csv",
"font": "./ubuntu.ttf", "font": "./ubuntu.ttf",
"fontSize": 22,
"xSize":2400, "xSize":2400,
"ySize":500, "ySize":500,
"panelLength":600, "panelLength":600,

View file

@ -83,7 +83,7 @@ def addThing(indVign,config):
return row[random.randint(3,len(row)-1)],row[1],row[2] return row[random.randint(3,len(row)-1)],row[1],row[2]
return 0 return 0
def writeStrip(story,fontSize,config): def writeStrip(story,config):
"""This function creates the strip returning an image object that could be saved or viewed. It takes an array with filenames as parameter """This function creates the strip returning an image object that could be saved or viewed. It takes an array with filenames as parameter
The first image is always 000, then appends to strip the files, then decorates it fetching text and adding objects. If the object is an R, then The first image is always 000, then appends to strip the files, then decorates it fetching text and adding objects. If the object is an R, then
repeats the last object.""" repeats the last object."""
@ -92,7 +92,7 @@ def writeStrip(story,fontSize,config):
try: try:
vign = Image.open(config["imagesLocation"]+"/"+indVign).convert('RGBA') vign = Image.open(config["imagesLocation"]+"/"+indVign).convert('RGBA')
addtext = ImageDraw.Draw(vign) addtext = ImageDraw.Draw(vign)
fnt = ImageFont.truetype(config["font"],fontSize) fnt = ImageFont.truetype(config["font"],config["fontSize"])
textVign = fetchText(indVign,config) textVign = fetchText(indVign,config)
if textVign!=0: if textVign!=0:
@ -132,13 +132,13 @@ def writeStrip(story,fontSize,config):
xshift += config["panelLength"] xshift += config["panelLength"]
return image return image
def createStrip(config,specialPlatform="",fontSize=22): def createStrip(config,specialPlatform=""):
"""Create strip and save it """Create strip and save it
createStrip(str path/filename)""" createStrip(str path/filename)"""
try: try:
story = fetchVign(config) story = fetchVign(config)
finalStrip = writeStrip(story,fontSize,config) finalStrip = writeStrip(story,config)
if specialPlatform == "android": if specialPlatform == "android":
return finalStrip return finalStrip
else: else:
@ -172,6 +172,7 @@ def readConfig(profile=False,platform=False):
csvSubs = config[profile]["csvSubs"] csvSubs = config[profile]["csvSubs"]
csvObj = config[profile]["csvObj"] csvObj = config[profile]["csvObj"]
font = checkLocal(config[profile]["font"]) font = checkLocal(config[profile]["font"])
fontSize = int((config[profile]["fontSize"]))
xSize = config[profile]["xSize"] xSize = config[profile]["xSize"]
ySize = config[profile]["ySize"] ySize = config[profile]["ySize"]
panelLength = config[profile]["panelLength"] panelLength = config[profile]["panelLength"]
@ -183,9 +184,9 @@ def readConfig(profile=False,platform=False):
except KeyError: except KeyError:
text = False text = False
return {"saveLocation":saveLocation,"imagesLocation":imagesLocation,"csvLocation":csvLocation,"font":font,"token":token,"filename":filename,"xSize":xSize,"ySize":ySize,"panelLength":panelLength,"csvTree":csvTree,"csvSpeech":csvSpeech,"csvSubs":csvSubs,"csvObj":csvObj,"text":text} return {"saveLocation":saveLocation,"imagesLocation":imagesLocation,"csvLocation":csvLocation,"fontSize":fontSize,"font":font,"token":token,"filename":filename,"xSize":xSize,"ySize":ySize,"panelLength":panelLength,"csvTree":csvTree,"csvSpeech":csvSpeech,"csvSubs":csvSubs,"csvObj":csvObj,"text":text}
filename = config[profile]["filename"] filename = config[profile]["filename"]
return {"saveLocation":saveLocation,"imagesLocation":imagesLocation,"csvLocation":csvLocation,"font":font,"filename":filename,"xSize":xSize,"ySize":ySize,"panelLength":panelLength,"csvTree":csvTree,"csvSpeech":csvSpeech,"csvSubs":csvSubs,"csvObj":csvObj} return {"saveLocation":saveLocation,"imagesLocation":imagesLocation,"csvLocation":csvLocation,"fontSize":fontSize,"font":font,"filename":filename,"xSize":xSize,"ySize":ySize,"panelLength":panelLength,"csvTree":csvTree,"csvSpeech":csvSpeech,"csvSubs":csvSubs,"csvObj":csvObj}
def checkLocal(directory): def checkLocal(directory):
"""Checks if it's a relative or absolute path""" """Checks if it's a relative or absolute path"""
@ -223,7 +224,7 @@ if __name__ == "__main__":
story = [] #Story specified story = [] #Story specified
for x in args.story: for x in args.story:
story.append(x) story.append(x)
finalStrip = writeStrip(story,22,config) finalStrip = writeStrip(story,config)
if args.xsize != 0: #Resize specified if args.xsize != 0: #Resize specified
finalStrip = finalStrip.resize((args.xsize[0],int(args.xsize[0]/2400*500))) finalStrip = finalStrip.resize((args.xsize[0],int(args.xsize[0]/2400*500)))