From e758473b3dcd9795ac0d15185384919d4e998780 Mon Sep 17 00:00:00 2001 From: Collin Heist Date: Sat, 10 Aug 2024 22:37:57 -0600 Subject: [PATCH] [61] (v1) Add --font-vertical-shift arg to Movie Posters in the mini maker --- mini_maker.py | 14 +++++++++++--- modules/MoviePosterMaker.py | 26 ++++---------------------- modules/ref/version_webui | 2 +- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/mini_maker.py b/mini_maker.py index dbd944ca..eb312f3b 100755 --- a/mini_maker.py +++ b/mini_maker.py @@ -201,9 +201,11 @@ def genre_card_batch( @click.option('--font', type=Path, default=MoviePosterMaker.FONT, help='Custom font for the title text') @click.option('--font-color', type=str, default=MoviePosterMaker.FONT_COLOR, - help='Font color for the title text(s)') + help='Font color for the title text') @click.option('--font-size', type=click.FloatRange(min=0.0), default=1.0, help='Font size scalar for the text') +@click.option('--font-vertical-shift', type=int, default=0, + help='Vertical shift to apply to title text') @click.option('--drop-shadow', is_flag=True, help='Whether to add a drop shadow to the text for the movie poster') @click.option('--borderless', is_flag=True, @@ -221,6 +223,7 @@ def create_movie_poster( font: Path, font_color: str, font_size: float, + font_vertical_shift: int, drop_shadow: bool, borderless: bool, omit_gradient: bool, @@ -237,6 +240,7 @@ def create_movie_poster( font_file=font, font_color=font_color, font_size=font_size, + font_vertical_shift=font_vertical_shift, borderless=borderless, add_drop_shadow=drop_shadow, omit_gradient=omit_gradient, @@ -324,6 +328,8 @@ class Show: help='Font size scalar for the season text') @click.option('--font-kerning', type=float, default=1.0, help='Font kerning scale for the season text') +@click.option('--font-vertical-shift', type=int, default=0, + help='Vertical shift to apply to the season text (in pixels)') @click.option('--logo-placement', type=click.Choice(['top', 'middle', 'bottom']), default='bottom', help='Placement of the logo') @@ -337,10 +343,11 @@ def season_poster( destination: Path, logo: Optional[Path], season_text: list[str], - font: Path, + font_file: Path, font_color: str, font_size: float, font_kerning: float, + font_vertical_shift: int, logo_placement: Literal['top', 'middle', 'bottom'], text_placement: Literal['top', 'bottom'], omit_gradient: bool, @@ -351,10 +358,11 @@ def season_poster( destination=destination, logo=logo, season_text='\n'.join(season_text), - font=font, font_color=font_color, + font=font_file, font_size=font_size, font_kerning=font_kerning, + font_vertical_shift=font_vertical_shift, logo_placement=logo_placement, text_placement=text_placement, omit_gradient=omit_gradient, diff --git a/modules/MoviePosterMaker.py b/modules/MoviePosterMaker.py index 3cfab61c..ab5d068d 100755 --- a/modules/MoviePosterMaker.py +++ b/modules/MoviePosterMaker.py @@ -32,32 +32,12 @@ def __init__(self, font_file: Path = FONT, font_color: str = FONT_COLOR, font_size: float = 1.0, + font_vertical_shift: int = 0, borderless: bool = False, add_drop_shadow: bool = False, omit_gradient: bool = False, ) -> None: - """ - Construct a new instance of a CollectionPosterMaker. - - Args: - source: The source image to use for the poster. - output: The output path to write the poster to. - title: String to use on the created poster. - subtitle: String to use for smaller title text. - top_subtitle: String to use for smaller subtitle text that - appears above the title text. - movie_index: Optional (series) index to place behind the - movie title. - logo: Optional path to a logo file to place on top of the - poster. - font_file: Path to the font file of the poster's title. - font_color: Font color of the poster text. - font_size: Scalar for the font size of the poster's title. - add_drop_shadow: Whether to add a drop shadow to the text. - borderless: Whether to omit the white frame border. - omit_gradient: Whether to make the poster with no gradient - overlay. - """ + """Construct a new instance of this object.""" # Initialize parent object for the ImageMagickInterface super().__init__() @@ -70,6 +50,7 @@ def __init__(self, self.font_file = font_file self.font_color = font_color self.font_size = font_size + self.font_vertical_shift = font_vertical_shift self.borderless = borderless self.add_drop_shadow = add_drop_shadow self.omit_gradient = omit_gradient @@ -223,6 +204,7 @@ def title_command(self) -> list[str]: f'-layers merge', f'+repage', ] + y_offset += self.font_vertical_shift # At least one title being added, return entire command return [ diff --git a/modules/ref/version_webui b/modules/ref/version_webui index 70ffb5c2..b7094357 100755 --- a/modules/ref/version_webui +++ b/modules/ref/version_webui @@ -1 +1 @@ -v2.0-alpha.11.0-webui60 \ No newline at end of file +v2.0-alpha.11.0-webui61 \ No newline at end of file