Random watermark position

main
Bob Mottram 2024-07-25 17:24:57 +01:00
parent c4ff723cfd
commit 11dd9c0e3c
3 changed files with 18 additions and 7 deletions

View File

@ -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.

View File

@ -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 = \

View File

@ -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: