feat: use thumb on album page

This commit is contained in:
starnakin 2025-05-02 13:29:09 -04:00
parent de051f222d
commit 08c0129af8
2 changed files with 12 additions and 2 deletions

View File

@ -17,6 +17,7 @@ class Picture():
def __init__(self, picture_path: Path, page = None, raw: Path|None = None, is_repertoried: bool = True): def __init__(self, picture_path: Path, page = None, raw: Path|None = None, is_repertoried: bool = True):
self._large: Path = picture_path self._large: Path = picture_path
self._small: Path = Path(picture_path.get_absolute_path()[:-4] + "_small.jpg") self._small: Path = Path(picture_path.get_absolute_path()[:-4] + "_small.jpg")
self._thumb: Path = Path(picture_path.get_absolute_path()[:-4] + "_thumb.jpg")
self._profile_file: Path = Path(picture_path.get_absolute_path() + ".out.pp3") self._profile_file: Path = Path(picture_path.get_absolute_path() + ".out.pp3")
self._albums_file: Path = Path(picture_path.get_absolute_path()[:-4] + "_albums.txt") self._albums_file: Path = Path(picture_path.get_absolute_path()[:-4] + "_albums.txt")
self._raw: Path|None = raw self._raw: Path|None = raw
@ -27,7 +28,6 @@ class Picture():
albums_name: list[str] = f.read() albums_name: list[str] = f.read()
if (len(albums_name)): if (len(albums_name)):
self._albums_name += albums_name.split("\n") self._albums_name += albums_name.split("\n")
print(self._albums_name)
else: else:
self._albums_file.touch() self._albums_file.touch()
if (config.CREATE_GENERAL_ALBUM): if (config.CREATE_GENERAL_ALBUM):
@ -45,12 +45,22 @@ class Picture():
self.gen_small() self.gen_small()
return self._small return self._small
def get_thumb(self):
if not self._thumb.exist():
self.gen_thumb()
return self._thumb
def get_large(self): def get_large(self):
return self._large return self._large
def get_profile_file(self): def get_profile_file(self):
return self._profile_file return self._profile_file
def gen_thumb(self):
im = Image.open(self._large.get_absolute_path())
im.thumbnail((500,500))
im.save(self._thumb.get_absolute_path(), "JPEG")
def gen_small(self): def gen_small(self):
im = Image.open(self._large.get_absolute_path()).convert("RGB") im = Image.open(self._large.get_absolute_path()).convert("RGB")
im.save(self._small.get_absolute_path(), quality=95, optimize=True) im.save(self._small.get_absolute_path(), quality=95, optimize=True)

View File

@ -10,7 +10,7 @@
<div class="picture-container"> <div class="picture-container">
{% for picture in album._pictures %} {% for picture in album._pictures %}
<a href="{{ picture.get_page().html.get_url() }}"> <a href="{{ picture.get_page().html.get_url() }}">
<img src="{{ picture.get_small().get_url() }}"> <img src="{{ picture.get_thumb().get_url() }}">
</a> </a>
{% endfor %} {% endfor %}
</div> </div>