improve image output format

This commit is contained in:
jiayiliu 2020-10-05 22:22:15 -07:00
parent 6942d2e44d
commit 6fa11437c0
4 changed files with 6 additions and 4 deletions

View File

@ -4,6 +4,8 @@ class Component():
"""
def __init__(self, label):
if label is None:
label = self.__class__.__name__
self.label = label
def get_template_context(self):

View File

@ -175,8 +175,7 @@ class Image(OutputComponent):
"""
im = processing_utils.decode_base64_to_image(data)
timestamp = datetime.datetime.now()
filename = 'output_{}.png'.format(timestamp.
strftime("%Y-%m-%d-%H-%M-%S"))
filename = 'output_{}_{}.png'.format(self.label, timestamp.strftime("%Y-%m-%d-%H-%M-%S"))
im.save('{}/{}'.format(dir, filename), 'PNG')
return filename

View File

@ -4,6 +4,8 @@ class Component():
"""
def __init__(self, label):
if label is None:
label = self.__class__.__name__
self.label = label
def get_template_context(self):

View File

@ -175,8 +175,7 @@ class Image(OutputComponent):
"""
im = processing_utils.decode_base64_to_image(data)
timestamp = datetime.datetime.now()
filename = 'output_{}.png'.format(timestamp.
strftime("%Y-%m-%d-%H-%M-%S"))
filename = 'output_{}_{}.png'.format(self.label, timestamp.strftime("%Y-%m-%d-%H-%M-%S"))
im.save('{}/{}'.format(dir, filename), 'PNG')
return filename