Thema
[librarian.git] / src / librarian / covers / widgets / image.py
1 import PIL.Image
2 from librarian import get_resource
3 from .base import Widget
4
5
6 class ImageWidget(Widget):
7     def build(self, w, h):
8         img = PIL.Image.open(self.image_path)
9         img = img.resize((round(img.size[0] / img.size[1] * h), h))
10         return img
11     
12     
13 class WLLogo(ImageWidget):
14     @property
15     def image_path(self):
16         if self.cover.color_scheme['text'] == '#fff':
17             return get_resource('res/cover/logo_WL_invert.png')
18         else:
19             return get_resource('res/cover/logo_WL.png')
20
21
22 class Label(ImageWidget):
23     @property
24     def image_path(self):
25         if self.cover.is_very_bright:
26             return get_resource('res/cover/label_WLpolecaja.szary.png')
27         else:
28             return get_resource('res/cover/label_WLpolecaja.png')
29