Skip to content

Commit

Permalink
Merge pull request #63 from CollinHeist/hotfix-windows-imagemagick
Browse files Browse the repository at this point in the history
Fix all non-docker ImageMagick calls on Windows
  • Loading branch information
CollinHeist authored Apr 10, 2022
2 parents f1a0699 + 33a2742 commit c8dc337
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

# Validate that ImageMagick is configured correctly
imi = ImageMagickInterface(pp.imagemagick_container)
font_output = imi.run_get_stdout('convert -list font')
font_output = imi.run_get_stdout('magick convert -list font')
if not all(_ in font_output for _ in ('Font:', 'family:', 'style:')):
log.critical(f"ImageMagick doesn't appear to be installed")
exit(1)
Expand Down
14 changes: 7 additions & 7 deletions modules/AnimeTitleCard.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __increase_contrast(self) -> Path:
"""

command = ' '.join([
f'convert "{self.source_file.resolve()}"',
f'magick convert "{self.source_file.resolve()}"',
f'+profile "*"', # To avoid profile conversion warnings
f'-modulate 100,125',
f'"{self.__CONSTRAST_SOURCE.resolve()}"',
Expand All @@ -217,7 +217,7 @@ def __add_gradient(self, image: Path) -> Path:
"""

command = ' '.join([
f'convert "{image.resolve()}"',
f'magick convert "{image.resolve()}"',
f'-gravity center', # For images that aren't 4x3, center crop
f'-resize "{self.TITLE_CARD_SIZE}^"',
f'-extent "{self.TITLE_CARD_SIZE}"',
Expand All @@ -243,7 +243,7 @@ def __add_title_text(self, gradient_image: Path) -> Path:
"""

command = ' '.join([
f'convert "{gradient_image.resolve()}"',
f'magick convert "{gradient_image.resolve()}"',
*self.__title_text_global_effects(),
*self.__title_text_black_stroke(),
f'-annotate +75+175 "{self.title}"',
Expand Down Expand Up @@ -271,7 +271,7 @@ def __add_title_and_kanji_text(self, gradient_image: Path) -> Path:
kanji_offset = 375 + (165 * (len(self.title.split('\n'))-1))

command = ' '.join([
f'convert "{gradient_image.resolve()}"',
f'magick convert "{gradient_image.resolve()}"',
*self.__title_text_global_effects(),
*self.__title_text_black_stroke(),
f'-annotate +75+175 "{self.title}"',
Expand Down Expand Up @@ -316,7 +316,7 @@ def __add_series_count_text(self, titled_image: Path) -> Path:

# Construct command for getting the width of the season text
width_command = ' '.join([
f'convert -debug annotate {titled_image.resolve()}',
f'magick convert -debug annotate {titled_image.resolve()}',
*season_text_command_list,
' null: 2>&1 | grep Metrics',
])
Expand All @@ -327,7 +327,7 @@ def __add_series_count_text(self, titled_image: Path) -> Path:

# Construct command to add season and episode text
command = ' '.join([
f'convert {titled_image.resolve()}',
f'magick convert {titled_image.resolve()}',
*season_text_command_list,
*self.__series_count_text_black_stroke(),
f'-annotate +{75+width}+90 "{self.episode_text}"',
Expand All @@ -352,7 +352,7 @@ def __add_series_count_text_no_season(self, titled_image: Path) -> Path:
"""

command = ' '.join([
f'convert "{titled_image.resolve()}"',
f'magick convert "{titled_image.resolve()}"',
*self.__series_count_text_global_effects(),
*self.__series_count_text_black_stroke(),
f'-annotate +75+90 "{self.episode_text}"',
Expand Down
12 changes: 6 additions & 6 deletions modules/StandardTitleCard.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _add_gradient(self) -> Path:
"""

command = ' '.join([
f'convert "{self.source_file.resolve()}"',
f'magick convert "{self.source_file.resolve()}"',
f'+profile "*"', # To avoid profile conversion warnings
f'-gravity center', # For images that aren't 4x3, center crop
f'-resize "{self.TITLE_CARD_SIZE}^"',
Expand Down Expand Up @@ -211,7 +211,7 @@ def _add_title_text(self, gradient_image: Path) -> Path:
vertical_shift = 245 + self.vertical_shift

command = ' '.join([
f'convert "{gradient_image.resolve()}"',
f'magick convert "{gradient_image.resolve()}"',
*self.__title_text_global_effects(),
*self.__title_text_black_stroke(),
f'-annotate +0+{vertical_shift} "{self.title}"',
Expand All @@ -235,7 +235,7 @@ def _add_series_count_text_no_season(self, titled_image: Path) -> Path:
"""

command = ' '.join([
f'convert "{titled_image.resolve()}"',
f'magick convert "{titled_image.resolve()}"',
*self.__series_count_text_global_effects(),
f'-font "{self.EPISODE_COUNT_FONT}"',
f'-gravity center',
Expand All @@ -259,7 +259,7 @@ def _get_series_count_text_dimensions(self) -> dict:
"""

command = ' '.join([
f'convert -debug annotate xc: ',
f'magick convert -debug annotate xc: ',
*self.__series_count_text_global_effects(),
f'-font "{self.SEASON_COUNT_FONT}"', # Season text
f'-gravity east',
Expand Down Expand Up @@ -299,7 +299,7 @@ def _create_series_count_text_image(self, width: float, width1: float,

# Create text only transparent image of season count text
command = ' '.join([
f'convert -size "{width}x{height}"',
f'magick convert -size "{width}x{height}"',
f'-alpha on',
f'-background transparent',
f'xc:transparent',
Expand Down Expand Up @@ -341,7 +341,7 @@ def _combine_titled_image_series_count_text(self, titled_image: Path,
"""

command = ' '.join([
f'composite',
f'magick composite',
f'-gravity center',
f'-geometry +0+690.2',
f'"{series_count_image.resolve()}"',
Expand Down
4 changes: 2 additions & 2 deletions modules/StarWarsTitleCard.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __add_star_gradient(self, source: Path) -> Path:
"""

command = ' '.join([
f'convert "{source.resolve()}"',
f'magick convert "{source.resolve()}"',
f'+profile "*"', # To avoid profile conversion warnings
f'-gravity center', # For images that aren't in 4x3, center crop
f'-resize "{self.TITLE_CARD_SIZE}^"',
Expand Down Expand Up @@ -211,7 +211,7 @@ def __add_text(self, gradient_source: Path) -> Path:
"""

command = ' '.join([
f'convert {gradient_source.resolve()}',
f'magick convert {gradient_source.resolve()}',
*self.__add_title_text(),
*self.__add_episode_prefix(),
*self.__add_episode_number_text(),
Expand Down

0 comments on commit c8dc337

Please sign in to comment.