adapted module for custom image class

This commit is contained in:
Ace 2020-12-02 01:01:00 +01:00
parent b6a64681a0
commit 5063117945
2 changed files with 15 additions and 20 deletions

View File

@ -27,9 +27,9 @@ class Inkyimage(inkycal_module):
"Only PNG and JPG/JPEG images are used for the slideshow." "Only PNG and JPG/JPEG images are used for the slideshow."
}, },
"use_colour": { "palette": {
"label":"Does the display support colour?", "label":"Which palette should be used for converting images?",
"options": [True, False] "options": ["bw", "bwr", "bwy"]
} }
} }
@ -61,7 +61,7 @@ class Inkyimage(inkycal_module):
# optional parameters # optional parameters
self.path = config['path'] self.path = config['path']
self.use_colour = config['use_colour'] self.palette = config['palette']
self.autoflip = config['autoflip'] self.autoflip = config['autoflip']
self.orientation = config['orientation'] self.orientation = config['orientation']
@ -95,12 +95,8 @@ class Inkyimage(inkycal_module):
# resize the image so it can fit on the epaper # resize the image so it can fit on the epaper
im.resize( width=im_width, height=im_height ) im.resize( width=im_width, height=im_height )
# convert images according to given settings # convert images according to specified palette
if self.use_colour == False: im_black, im_colour = im.to_palette(self.palette)
im_black = im.to_mono()
im_colour = Image.new('RGB', size = im_black.size, color = 'white')
else:
im_black, im_colour = im.to_colour()
# with the images now send, clear the current image # with the images now send, clear the current image
im.clear() im.clear()

View File

@ -28,9 +28,9 @@ class Slideshow(inkycal_module):
"Only PNG and JPG/JPEG images are used for the slideshow." "Only PNG and JPG/JPEG images are used for the slideshow."
}, },
"use_colour": { "palette": {
"label":"Does the display support colour?", "label":"Which palette should be used for converting images?",
"options": [True, False] "options": ["bw", "bwr", "bwy"]
} }
} }
@ -62,7 +62,7 @@ class Slideshow(inkycal_module):
# optional parameters # optional parameters
self.path = config['path'] self.path = config['path']
self.use_colour = config['use_colour'] self.palette = config['palette']
self.autoflip = config['autoflip'] self.autoflip = config['autoflip']
self.orientation = config['orientation'] self.orientation = config['orientation']
@ -105,6 +105,9 @@ class Slideshow(inkycal_module):
# initialize custom image class # initialize custom image class
im = Images() im = Images()
# temporary print method, prints current filename
print(f'slideshow - current image name: {self.images[0].split("/")[-1]}')
# use the image at the first index # use the image at the first index
im.load(self.images[0]) im.load(self.images[0])
@ -118,12 +121,8 @@ class Slideshow(inkycal_module):
# resize the image so it can fit on the epaper # resize the image so it can fit on the epaper
im.resize( width=im_width, height=im_height ) im.resize( width=im_width, height=im_height )
# convert images according to given settings # convert images according to specified palette
if self.use_colour == False: im_black, im_colour = im.to_palette(self.palette)
im_black = im.to_mono()
im_colour = Image.new('RGB', size = im_black.size, color = 'white')
else:
im_black, im_colour = im.to_colour()
# with the images now send, clear the current image # with the images now send, clear the current image
im.clear() im.clear()