add: multithread gen assets
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from PIL import Image
|
||||
import os
|
||||
import thread_manager
|
||||
|
||||
from path import Path
|
||||
|
||||
@ -61,12 +61,16 @@ class Picture():
|
||||
return self._profile_file
|
||||
|
||||
def gen_thumb(self):
|
||||
im = Image.open(self._large.get_absolute_path())
|
||||
im.thumbnail(config.THUMB_DIMENSION)
|
||||
im.save(self._thumb.get_absolute_path(), "JPEG")
|
||||
def _(_large: Path, _thumb: Path):
|
||||
im = Image.open(_large.get_absolute_path())
|
||||
im.thumbnail(config.THUMB_DIMENSION)
|
||||
im.save(_thumb.get_absolute_path(), "JPEG")
|
||||
thread_manager.add_to_queu(_, (self._large, self._thumb))
|
||||
|
||||
def gen_small(self):
|
||||
im = Image.open(self._large.get_absolute_path()).convert("RGB")
|
||||
im.save(self._small.get_absolute_path(), quality=95, optimize=True)
|
||||
def _(_large: Path, _small: Path):
|
||||
im = Image.open(_large.get_absolute_path()).convert("RGB")
|
||||
im.save(_small.get_absolute_path(), quality=95, optimize=True)
|
||||
thread_manager.add_to_queu(_, (self._large, self._small))
|
||||
|
||||
|
Reference in New Issue
Block a user