Skip to content

Commit

Permalink
Merge branch 'create-thumbnail'
Browse files Browse the repository at this point in the history
  • Loading branch information
153957 committed Sep 10, 2023
2 parents cbf192d + ae32964 commit a05f824
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ classifiers = [
dependencies = [
'exifreader==0.1.1',
'ffmpeg-python==0.2.0',
'pillow==10.0.0',
]

[project.optional-dependencies]
Expand Down
23 changes: 23 additions & 0 deletions time_lapse/thumbnail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pathlib
import shutil

from PIL import Image


def create_thumbnail(
name: str,
poster_path: pathlib.Path,
width: int = 180,
height: int = 120,
) -> None:
target_path = pathlib.Path() / f'{name}{poster_path.suffix}'
thumbnail_path = target_path.parent / f'{name}@2x.png'
with Image.open(poster_path) as image:
image.resize(
size=(width, height),
resample=Image.LANCZOS,
).save(
thumbnail_path,
compress=False,
)
shutil.copy(poster_path, target_path)

0 comments on commit a05f824

Please sign in to comment.