diff --git a/README_commandline.md b/README_commandline.md index 7fbc768c5..39070691c 100644 --- a/README_commandline.md +++ b/README_commandline.md @@ -443,7 +443,7 @@ The watermark image can be set via editing your profile and then going to the ** The opacity is a percentage value, and you could potentially use 100% opacity together with a watermark which has a transparent background. -The watermark position is a compass direction: north, south, east, west, or combinations thereof. +The watermark position is a compass direction: north, south, east, west, or combinations thereof. It can also be set to "random" to choose a random position. Random positioning will make it more difficult for any scraper bot to try to remove. Even if the scraper bot tries to remove your watermark from the image by filling in from the surrounding pixels, the removal itself may leave a detectable trace indicative of improper use. diff --git a/epicyon.py b/epicyon.py index 625bac876..16b098908 100644 --- a/epicyon.py +++ b/epicyon.py @@ -262,7 +262,7 @@ def _command_options() -> None: help='Opacity of watermark applied to attached images') parser.add_argument('--watermarkPosition', dest='watermark_position', type=str, - default="east", + default="random", help='Position of image watermarks ' + 'north/south/east/west') parser.add_argument('--check-actor-timeout', dest='check_actor_timeout', @@ -3879,7 +3879,8 @@ def _command_options() -> None: if argb.watermark_position.lower() not in ('north', 'south', 'east', 'west', 'northeast', 'northwest', - 'southeast', 'southwest'): + 'southeast', 'southwest', + 'random'): argb.watermark_position = 'east' watermark_opacity = \ diff --git a/media.py b/media.py index 24b73aff4..9126c864f 100644 --- a/media.py +++ b/media.py @@ -795,12 +795,22 @@ def apply_watermark_to_image(base_dir: str, nickname: str, domain: str, int(watermark_image_height * scaled_watermark_image_width / watermark_image_width) - if watermark_position.lower() not in ('north', 'south', - 'east', 'west', - 'northeast', 'northwest', - 'southeast', 'southwest'): + watermark_position = watermark_position.lower() + if watermark_position not in ('north', 'south', + 'east', 'west', + 'northeast', 'northwest', + 'southeast', 'southwest', + 'random'): watermark_position = 'east' + # choose a random position for the watermark + if watermark_position == 'random': + watermark_position = \ + random.choice(['north', 'south', + 'east', 'west', + 'northeast', 'northwest', + 'southeast', 'southwest']) + if watermark_opacity < 0: watermark_opacity = 0 if watermark_opacity > 100: