Skip to content

Commit

Permalink
Merge pull request #114 from pelican-plugins/fix_issue_with_font_size…
Browse files Browse the repository at this point in the history
…_too_small

Fix issue with font size to small
  • Loading branch information
phibos authored Mar 5, 2024
2 parents e92c308 + 5c4f4b5 commit edb9bb2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pelican/plugins/photos/photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,16 +1309,20 @@ def _operation_watermark(self, image: PILImage.Image) -> PILImage.Image:
image_reducer = 8
text_size = [0, 0]
mark_size = [0, 0]
text_position = [0, 0]

if self._pelican_settings["PHOTO_WATERMARK_TEXT"]:
font_name = "SourceCodePro-Bold.otf"
default_font = os.path.join(
os.path.dirname(os.path.realpath(__file__)), font_name
)
font = ImageFont.FreeTypeFont(
default_font, watermark_layer.size[0] // text_reducer
)
font_size = watermark_layer.size[0] // text_reducer
if font_size < 1:
logger.info(
f"photos: font size {font_size} is to small skipping watermark"
)
return image

font = ImageFont.FreeTypeFont(font=default_font, size=font_size)
text_size[0] = draw_watermark.textlength(
self._pelican_settings["PHOTO_WATERMARK_TEXT"], font, direction="rtl"
)
Expand Down

0 comments on commit edb9bb2

Please sign in to comment.