mirror of https://gitlab.com/bashrc2/epicyon
Option to set watermark opacity on attached images
parent
19160226a9
commit
e24455c816
|
@ -760,7 +760,8 @@ def run_daemon(accounts_data_dir: str,
|
||||||
send_threads: [],
|
send_threads: [],
|
||||||
manual_follower_approval: bool,
|
manual_follower_approval: bool,
|
||||||
watermark_width_percent: int,
|
watermark_width_percent: int,
|
||||||
watermark_position: str) -> None:
|
watermark_position: str,
|
||||||
|
watermark_opacity: int) -> None:
|
||||||
if len(domain) == 0:
|
if len(domain) == 0:
|
||||||
domain = 'localhost'
|
domain = 'localhost'
|
||||||
if '.' not in domain:
|
if '.' not in domain:
|
||||||
|
@ -804,10 +805,11 @@ def run_daemon(accounts_data_dir: str,
|
||||||
|
|
||||||
httpd.starting_daemon = True
|
httpd.starting_daemon = True
|
||||||
|
|
||||||
# width of watermark applied to attached images
|
# width, position and opacity of watermark applied to attached images
|
||||||
# as a percentage of the attached image width
|
# as a percentage of the attached image width
|
||||||
httpd.watermark_width_percent = watermark_width_percent
|
httpd.watermark_width_percent = watermark_width_percent
|
||||||
httpd.watermark_position = watermark_position
|
httpd.watermark_position = watermark_position
|
||||||
|
httpd.watermark_opacity = watermark_opacity
|
||||||
|
|
||||||
# for each account whether to hide announces
|
# for each account whether to hide announces
|
||||||
httpd.hide_announces = {}
|
httpd.hide_announces = {}
|
||||||
|
|
|
@ -869,7 +869,8 @@ def daemon_http_post(self) -> None:
|
||||||
self.server.i2p_domain,
|
self.server.i2p_domain,
|
||||||
self.server.max_shares_on_profile,
|
self.server.max_shares_on_profile,
|
||||||
self.server.watermark_width_percent,
|
self.server.watermark_width_percent,
|
||||||
self.server.watermark_position)
|
self.server.watermark_position,
|
||||||
|
self.server.watermark_opacity)
|
||||||
if page_number:
|
if page_number:
|
||||||
print(curr_post_type + ' post received')
|
print(curr_post_type + ' post received')
|
||||||
nickname = self.path.split('/users/')[1]
|
nickname = self.path.split('/users/')[1]
|
||||||
|
|
|
@ -1597,7 +1597,8 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||||
i2p_domain: str,
|
i2p_domain: str,
|
||||||
max_shares_on_profile: int,
|
max_shares_on_profile: int,
|
||||||
watermark_width_percent: int,
|
watermark_width_percent: int,
|
||||||
watermark_position: str) -> int:
|
watermark_position: str,
|
||||||
|
watermark_opacity: int) -> int:
|
||||||
# Note: this needs to happen synchronously
|
# Note: this needs to happen synchronously
|
||||||
# 0=this is not a new post
|
# 0=this is not a new post
|
||||||
# 1=new post success
|
# 1=new post success
|
||||||
|
@ -1691,7 +1692,8 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||||
convert_image_to_low_bandwidth(filename)
|
convert_image_to_low_bandwidth(filename)
|
||||||
apply_watermark_to_image(base_dir, nickname, domain,
|
apply_watermark_to_image(base_dir, nickname, domain,
|
||||||
filename, watermark_width_percent,
|
filename, watermark_width_percent,
|
||||||
watermark_position)
|
watermark_position,
|
||||||
|
watermark_opacity)
|
||||||
post_image_filename = filename.replace('.temp', '')
|
post_image_filename = filename.replace('.temp', '')
|
||||||
print('Removing metadata from ' + post_image_filename)
|
print('Removing metadata from ' + post_image_filename)
|
||||||
city = get_spoofed_city(city, base_dir, nickname, domain)
|
city = get_spoofed_city(city, base_dir, nickname, domain)
|
||||||
|
@ -2200,7 +2202,8 @@ def receive_new_post(self, post_type, path: str,
|
||||||
i2p_domain: str,
|
i2p_domain: str,
|
||||||
max_shares_on_profile: int,
|
max_shares_on_profile: int,
|
||||||
watermark_width_percent: int,
|
watermark_width_percent: int,
|
||||||
watermark_position: str) -> int:
|
watermark_position: str,
|
||||||
|
watermark_opacity: int) -> int:
|
||||||
"""A new post has been created
|
"""A new post has been created
|
||||||
This creates a thread to send the new post
|
This creates a thread to send the new post
|
||||||
"""
|
"""
|
||||||
|
@ -2340,7 +2343,8 @@ def receive_new_post(self, post_type, path: str,
|
||||||
i2p_domain,
|
i2p_domain,
|
||||||
max_shares_on_profile,
|
max_shares_on_profile,
|
||||||
watermark_width_percent,
|
watermark_width_percent,
|
||||||
watermark_position)
|
watermark_position,
|
||||||
|
watermark_opacity)
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: _receive_new_post_process returned ' +
|
print('DEBUG: _receive_new_post_process returned ' +
|
||||||
str(retval))
|
str(retval))
|
||||||
|
|
16
epicyon.py
16
epicyon.py
|
@ -256,6 +256,10 @@ def _command_options() -> None:
|
||||||
default=30,
|
default=30,
|
||||||
help='Width of the watermark applied to attached ' +
|
help='Width of the watermark applied to attached ' +
|
||||||
'images as a percentage of the attached image width')
|
'images as a percentage of the attached image width')
|
||||||
|
parser.add_argument('--watermarkOpacity',
|
||||||
|
dest='watermark_opacity', type=int,
|
||||||
|
default=10,
|
||||||
|
help='Opacity of watermark applied to attached images')
|
||||||
parser.add_argument('--watermarkPosition',
|
parser.add_argument('--watermarkPosition',
|
||||||
dest='watermark_position', type=str,
|
dest='watermark_position', type=str,
|
||||||
default="east",
|
default="east",
|
||||||
|
@ -3878,6 +3882,15 @@ def _command_options() -> None:
|
||||||
'southeast', 'southwest'):
|
'southeast', 'southwest'):
|
||||||
argb.watermark_position = 'east'
|
argb.watermark_position = 'east'
|
||||||
|
|
||||||
|
watermark_opacity = \
|
||||||
|
get_config_param(base_dir, 'watermarkOpacity')
|
||||||
|
if watermark_opacity is not None:
|
||||||
|
argb.watermark_opacity = int(watermark_opacity)
|
||||||
|
if argb.watermark_opacity < 0:
|
||||||
|
argb.watermark_opacity = 0
|
||||||
|
if argb.watermark_opacity > 100:
|
||||||
|
argb.watermark_opacity = 100
|
||||||
|
|
||||||
show_publish_as_icon = \
|
show_publish_as_icon = \
|
||||||
get_config_param(base_dir, 'showPublishAsIcon')
|
get_config_param(base_dir, 'showPublishAsIcon')
|
||||||
if show_publish_as_icon is not None:
|
if show_publish_as_icon is not None:
|
||||||
|
@ -4111,4 +4124,5 @@ if __name__ == "__main__":
|
||||||
argb2.instance_only_skills_search, [],
|
argb2.instance_only_skills_search, [],
|
||||||
not argb2.noapproval,
|
not argb2.noapproval,
|
||||||
argb2.watermark_width_percent,
|
argb2.watermark_width_percent,
|
||||||
argb2.watermark_position)
|
argb2.watermark_position,
|
||||||
|
argb2.watermark_opacity)
|
||||||
|
|
11
media.py
11
media.py
|
@ -766,7 +766,8 @@ def get_image_dimensions(image_filename: str) -> (int, int):
|
||||||
def apply_watermark_to_image(base_dir: str, nickname: str, domain: str,
|
def apply_watermark_to_image(base_dir: str, nickname: str, domain: str,
|
||||||
post_image_filename: str,
|
post_image_filename: str,
|
||||||
watermark_width_percent: int,
|
watermark_width_percent: int,
|
||||||
watermark_position: str) -> bool:
|
watermark_position: str,
|
||||||
|
watermark_opacity: int) -> bool:
|
||||||
"""Applies a watermark to the given image
|
"""Applies a watermark to the given image
|
||||||
"""
|
"""
|
||||||
if not os.path.isfile(post_image_filename):
|
if not os.path.isfile(post_image_filename):
|
||||||
|
@ -800,11 +801,17 @@ def apply_watermark_to_image(base_dir: str, nickname: str, domain: str,
|
||||||
'southeast', 'southwest'):
|
'southeast', 'southwest'):
|
||||||
watermark_position = 'east'
|
watermark_position = 'east'
|
||||||
|
|
||||||
|
if watermark_opacity < 0:
|
||||||
|
watermark_opacity = 0
|
||||||
|
if watermark_opacity > 100:
|
||||||
|
watermark_opacity = 100
|
||||||
|
|
||||||
cmd = \
|
cmd = \
|
||||||
'/usr/bin/composite ' + \
|
'/usr/bin/composite ' + \
|
||||||
'-geometry ' + str(scaled_watermark_image_width) + 'x' + \
|
'-geometry ' + str(scaled_watermark_image_width) + 'x' + \
|
||||||
str(scaled_watermark_image_height) + '+30+5 ' + \
|
str(scaled_watermark_image_height) + '+30+5 ' + \
|
||||||
'-watermark 10% -gravity ' + watermark_position + ' ' + \
|
'-watermark ' + str(watermark_opacity) + '% ' + \
|
||||||
|
'-gravity ' + watermark_position + ' ' + \
|
||||||
safe_system_string(watermark_filename) + ' ' + \
|
safe_system_string(watermark_filename) + ' ' + \
|
||||||
safe_system_string(post_image_filename) + ' ' + \
|
safe_system_string(post_image_filename) + ' ' + \
|
||||||
safe_system_string(post_image_filename + '.watermarked')
|
safe_system_string(post_image_filename + '.watermarked')
|
||||||
|
|
13
tests.py
13
tests.py
|
@ -895,6 +895,7 @@ def create_server_alice(path: str, domain: str, port: int,
|
||||||
accounts_data_dir = None
|
accounts_data_dir = None
|
||||||
watermark_width_percent = 30
|
watermark_width_percent = 30
|
||||||
watermark_position = 'east'
|
watermark_position = 'east'
|
||||||
|
watermark_opacity = 10
|
||||||
print('Server running: Alice')
|
print('Server running: Alice')
|
||||||
run_daemon(accounts_data_dir,
|
run_daemon(accounts_data_dir,
|
||||||
no_of_books, public_replies_unlisted,
|
no_of_books, public_replies_unlisted,
|
||||||
|
@ -927,7 +928,7 @@ def create_server_alice(path: str, domain: str, port: int,
|
||||||
domain_max_posts_per_day, account_max_posts_per_day,
|
domain_max_posts_per_day, account_max_posts_per_day,
|
||||||
allow_deletion, True, True, False, send_threads,
|
allow_deletion, True, True, False, send_threads,
|
||||||
False, watermark_width_percent,
|
False, watermark_width_percent,
|
||||||
watermark_position)
|
watermark_position, watermark_opacity)
|
||||||
|
|
||||||
|
|
||||||
def create_server_bob(path: str, domain: str, port: int,
|
def create_server_bob(path: str, domain: str, port: int,
|
||||||
|
@ -1084,6 +1085,7 @@ def create_server_bob(path: str, domain: str, port: int,
|
||||||
accounts_data_dir = None
|
accounts_data_dir = None
|
||||||
watermark_width_percent = 30
|
watermark_width_percent = 30
|
||||||
watermark_position = 'east'
|
watermark_position = 'east'
|
||||||
|
watermark_opacity = 10
|
||||||
print('Server running: Bob')
|
print('Server running: Bob')
|
||||||
run_daemon(accounts_data_dir,
|
run_daemon(accounts_data_dir,
|
||||||
no_of_books, public_replies_unlisted,
|
no_of_books, public_replies_unlisted,
|
||||||
|
@ -1116,7 +1118,7 @@ def create_server_bob(path: str, domain: str, port: int,
|
||||||
domain_max_posts_per_day, account_max_posts_per_day,
|
domain_max_posts_per_day, account_max_posts_per_day,
|
||||||
allow_deletion, True, True, False, send_threads,
|
allow_deletion, True, True, False, send_threads,
|
||||||
False, watermark_width_percent,
|
False, watermark_width_percent,
|
||||||
watermark_position)
|
watermark_position, watermark_opacity)
|
||||||
|
|
||||||
|
|
||||||
def create_server_eve(path: str, domain: str, port: int, federation_list: [],
|
def create_server_eve(path: str, domain: str, port: int, federation_list: [],
|
||||||
|
@ -1181,6 +1183,7 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [],
|
||||||
accounts_data_dir = None
|
accounts_data_dir = None
|
||||||
watermark_width_percent = 30
|
watermark_width_percent = 30
|
||||||
watermark_position = 'east'
|
watermark_position = 'east'
|
||||||
|
watermark_opacity = 10
|
||||||
print('Server running: Eve')
|
print('Server running: Eve')
|
||||||
run_daemon(accounts_data_dir, no_of_books,
|
run_daemon(accounts_data_dir, no_of_books,
|
||||||
public_replies_unlisted,
|
public_replies_unlisted,
|
||||||
|
@ -1234,7 +1237,8 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [],
|
||||||
True, True, False,
|
True, True, False,
|
||||||
send_threads, False,
|
send_threads, False,
|
||||||
watermark_width_percent,
|
watermark_width_percent,
|
||||||
watermark_position)
|
watermark_position,
|
||||||
|
watermark_opacity)
|
||||||
|
|
||||||
|
|
||||||
def create_server_group(path: str, domain: str, port: int,
|
def create_server_group(path: str, domain: str, port: int,
|
||||||
|
@ -1301,6 +1305,7 @@ def create_server_group(path: str, domain: str, port: int,
|
||||||
accounts_data_dir = None
|
accounts_data_dir = None
|
||||||
watermark_width_percent = 30
|
watermark_width_percent = 30
|
||||||
watermark_position = 'east'
|
watermark_position = 'east'
|
||||||
|
watermark_opacity = 10
|
||||||
print('Server running: Group')
|
print('Server running: Group')
|
||||||
run_daemon(accounts_data_dir,
|
run_daemon(accounts_data_dir,
|
||||||
no_of_books, public_replies_unlisted,
|
no_of_books, public_replies_unlisted,
|
||||||
|
@ -1333,7 +1338,7 @@ def create_server_group(path: str, domain: str, port: int,
|
||||||
domain_max_posts_per_day, account_max_posts_per_day,
|
domain_max_posts_per_day, account_max_posts_per_day,
|
||||||
allow_deletion, True, True, False, send_threads,
|
allow_deletion, True, True, False, send_threads,
|
||||||
False, watermark_width_percent,
|
False, watermark_width_percent,
|
||||||
watermark_position)
|
watermark_position, watermark_opacity)
|
||||||
|
|
||||||
|
|
||||||
def test_post_message_between_servers(base_dir: str) -> None:
|
def test_post_message_between_servers(base_dir: str) -> None:
|
||||||
|
|
Loading…
Reference in New Issue