Skip to content

Commit

Permalink
Added image shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
jinglemansweep committed Jun 6, 2024
1 parent 26c78ea commit c6620a4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions inkyframeweb/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
image_files = glob_images(Path(output.image_path))
output_display = OutputDisplay(
image_files,
output.get("image_shuffle", False),
output.get("overlay_x", config.default.overlay_x),
output.get("overlay_y", config.default.overlay_y),
output.get("overlay_size", config.default.overlay_size),
Expand Down
5 changes: 5 additions & 0 deletions inkyframeweb/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
default="images/samples",
cast=Path,
),
Validator(
"OUTPUTS__0__IMAGE_SHUFFLE",
default=False,
cast=bool,
),
Validator(
"OUTPUTS__0__OVERLAY_X",
default=0,
Expand Down
3 changes: 2 additions & 1 deletion inkyframeweb/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@


def glob_images(
directory: Path, patterns: List[str] = ["*.jpg", "*.jpeg", "*.png", "*.gif"]
directory: Path,
patterns: List[str] = ["*.jpg", "*.jpeg", "*.png", "*.gif"],
) -> List[Path]:
# Glob all image files in the directory
image_files: List[Path] = []
Expand Down
7 changes: 7 additions & 0 deletions inkyframeweb/outputs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import random
from pathlib import Path
from typing import List

Expand All @@ -6,13 +7,17 @@ class OutputDisplay:
def __init__(
self,
image_files: List[Path],
image_shuffle: bool,
overlay_x: int,
overlay_y: int,
overlay_size: int,
overlay_format: str,
overlay_color: str,
) -> None:
self.image_files = image_files
self.image_shuffle = image_shuffle
if image_shuffle:
random.shuffle(self.image_files)
self.image_count = len(image_files)
self.image_index = 0
self.image_iter = 0
Expand All @@ -35,6 +40,8 @@ def __repr__(self) -> str:
return (
"<OutputDisplay items="
+ str(len(self.image_files))
+ " shuffle="
+ str(self.image_shuffle)
+ " index="
+ str(self.image_index)
+ " image_iter="
Expand Down
1 change: 1 addition & 0 deletions settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
[outputs]
# [outputs.0]
# image_path = "images/samples"
# image_shuffle = false
# overlay_x = 0
# overlay_y = 0
# overlay_size = 16
Expand Down

0 comments on commit c6620a4

Please sign in to comment.