mirror of https://gitlab.com/bashrc2/epicyon
Option to set watermark position
parent
98ad4609b4
commit
b70ae582d9
|
@ -759,7 +759,8 @@ def run_daemon(accounts_data_dir: str,
|
||||||
instance_only_skills_search: bool,
|
instance_only_skills_search: bool,
|
||||||
send_threads: [],
|
send_threads: [],
|
||||||
manual_follower_approval: bool,
|
manual_follower_approval: bool,
|
||||||
watermark_width_percent: int) -> None:
|
watermark_width_percent: int,
|
||||||
|
watermark_position: str) -> None:
|
||||||
if len(domain) == 0:
|
if len(domain) == 0:
|
||||||
domain = 'localhost'
|
domain = 'localhost'
|
||||||
if '.' not in domain:
|
if '.' not in domain:
|
||||||
|
@ -806,6 +807,7 @@ def run_daemon(accounts_data_dir: str,
|
||||||
# width of watermark applied to attached images
|
# width 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
|
||||||
|
|
||||||
# for each account whether to hide announces
|
# for each account whether to hide announces
|
||||||
httpd.hide_announces = {}
|
httpd.hide_announces = {}
|
||||||
|
|
|
@ -2524,11 +2524,6 @@ def daemon_http_get(self) -> None:
|
||||||
self.server.debug):
|
self.server.debug):
|
||||||
return
|
return
|
||||||
|
|
||||||
# watermark for image uploads/attachments
|
|
||||||
if self.path.endswith('/watermark_image.png'):
|
|
||||||
# TODO
|
|
||||||
return
|
|
||||||
|
|
||||||
fitness_performance(getreq_start_time, self.server.fitness,
|
fitness_performance(getreq_start_time, self.server.fitness,
|
||||||
'_GET', 'search screen banner done',
|
'_GET', 'search screen banner done',
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
|
|
|
@ -868,7 +868,8 @@ def daemon_http_post(self) -> None:
|
||||||
self.server.onion_domain,
|
self.server.onion_domain,
|
||||||
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)
|
||||||
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]
|
||||||
|
|
|
@ -1596,7 +1596,8 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||||
onion_domain: str,
|
onion_domain: str,
|
||||||
i2p_domain: str,
|
i2p_domain: str,
|
||||||
max_shares_on_profile: int,
|
max_shares_on_profile: int,
|
||||||
watermark_width_percent: int) -> int:
|
watermark_width_percent: int,
|
||||||
|
watermark_position: str) -> 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
|
||||||
|
@ -1689,7 +1690,8 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||||
print('Converting to low bandwidth ' + filename)
|
print('Converting to low bandwidth ' + filename)
|
||||||
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)
|
||||||
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)
|
||||||
|
@ -2197,7 +2199,8 @@ def receive_new_post(self, post_type, path: str,
|
||||||
onion_domain: str,
|
onion_domain: str,
|
||||||
i2p_domain: str,
|
i2p_domain: str,
|
||||||
max_shares_on_profile: int,
|
max_shares_on_profile: int,
|
||||||
watermark_width_percent: int) -> int:
|
watermark_width_percent: int,
|
||||||
|
watermark_position: str) -> 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
|
||||||
"""
|
"""
|
||||||
|
@ -2336,7 +2339,8 @@ def receive_new_post(self, post_type, path: str,
|
||||||
onion_domain,
|
onion_domain,
|
||||||
i2p_domain,
|
i2p_domain,
|
||||||
max_shares_on_profile,
|
max_shares_on_profile,
|
||||||
watermark_width_percent)
|
watermark_width_percent,
|
||||||
|
watermark_position)
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: _receive_new_post_process returned ' +
|
print('DEBUG: _receive_new_post_process returned ' +
|
||||||
str(retval))
|
str(retval))
|
||||||
|
|
18
epicyon.py
18
epicyon.py
|
@ -256,6 +256,11 @@ 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('--watermarkPosition',
|
||||||
|
dest='watermark_position', type=str,
|
||||||
|
default="east",
|
||||||
|
help='Position of image watermarks ' +
|
||||||
|
'north/south/east/west')
|
||||||
parser.add_argument('--check-actor-timeout', dest='check_actor_timeout',
|
parser.add_argument('--check-actor-timeout', dest='check_actor_timeout',
|
||||||
type=int, default=2,
|
type=int, default=2,
|
||||||
help='Timeout in seconds used for checking is ' +
|
help='Timeout in seconds used for checking is ' +
|
||||||
|
@ -3863,6 +3868,16 @@ def _command_options() -> None:
|
||||||
if argb.watermark_width_percent > 100:
|
if argb.watermark_width_percent > 100:
|
||||||
argb.watermark_width_percent = 100
|
argb.watermark_width_percent = 100
|
||||||
|
|
||||||
|
watermark_position = \
|
||||||
|
get_config_param(base_dir, 'watermarkPosition')
|
||||||
|
if watermark_position is not None:
|
||||||
|
argb.watermark_position = watermark_width_percent
|
||||||
|
if argb.watermark_position.lower() not in ('north', 'south',
|
||||||
|
'east', 'west',
|
||||||
|
'northeast', 'northwest',
|
||||||
|
'southeast', 'southwest'):
|
||||||
|
argb.watermark_position = 'east'
|
||||||
|
|
||||||
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:
|
||||||
|
@ -4095,4 +4110,5 @@ if __name__ == "__main__":
|
||||||
argb2.allowdeletion, opt2['debug'], False,
|
argb2.allowdeletion, opt2['debug'], False,
|
||||||
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)
|
||||||
|
|
11
media.py
11
media.py
|
@ -765,7 +765,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) -> bool:
|
watermark_width_percent: int,
|
||||||
|
watermark_position: str) -> 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):
|
||||||
|
@ -789,11 +790,17 @@ def apply_watermark_to_image(base_dir: str, nickname: str, domain: str,
|
||||||
int(watermark_image_height *
|
int(watermark_image_height *
|
||||||
scaled_watermark_image_width / watermark_image_width)
|
scaled_watermark_image_width / watermark_image_width)
|
||||||
|
|
||||||
|
if watermark_position.lower() not in ('north', 'south',
|
||||||
|
'east', 'west',
|
||||||
|
'northeast', 'northwest',
|
||||||
|
'southeast', 'southwest'):
|
||||||
|
watermark_position = 'east'
|
||||||
|
|
||||||
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 east ' + \
|
'-watermark 10% -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')
|
||||||
|
|
24
tests.py
24
tests.py
|
@ -893,7 +893,8 @@ def create_server_alice(path: str, domain: str, port: int,
|
||||||
public_replies_unlisted = False
|
public_replies_unlisted = False
|
||||||
no_of_books = 10
|
no_of_books = 10
|
||||||
accounts_data_dir = None
|
accounts_data_dir = None
|
||||||
watermark_width_percent = 20
|
watermark_width_percent = 30
|
||||||
|
watermark_position = 'east'
|
||||||
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,
|
||||||
|
@ -925,7 +926,8 @@ def create_server_alice(path: str, domain: str, port: int,
|
||||||
proxy_type, max_replies,
|
proxy_type, max_replies,
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
def create_server_bob(path: str, domain: str, port: int,
|
def create_server_bob(path: str, domain: str, port: int,
|
||||||
|
@ -1080,7 +1082,8 @@ def create_server_bob(path: str, domain: str, port: int,
|
||||||
public_replies_unlisted = False
|
public_replies_unlisted = False
|
||||||
no_of_books = 10
|
no_of_books = 10
|
||||||
accounts_data_dir = None
|
accounts_data_dir = None
|
||||||
watermark_width_percent = 20
|
watermark_width_percent = 30
|
||||||
|
watermark_position = 'east'
|
||||||
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,
|
||||||
|
@ -1112,7 +1115,8 @@ def create_server_bob(path: str, domain: str, port: int,
|
||||||
proxy_type, max_replies,
|
proxy_type, max_replies,
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
def create_server_eve(path: str, domain: str, port: int, federation_list: [],
|
def create_server_eve(path: str, domain: str, port: int, federation_list: [],
|
||||||
|
@ -1175,7 +1179,8 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [],
|
||||||
domain_max_posts_per_day = 1000
|
domain_max_posts_per_day = 1000
|
||||||
account_max_posts_per_day = 1000
|
account_max_posts_per_day = 1000
|
||||||
accounts_data_dir = None
|
accounts_data_dir = None
|
||||||
watermark_width_percent = 20
|
watermark_width_percent = 30
|
||||||
|
watermark_position = 'east'
|
||||||
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,
|
||||||
|
@ -1228,7 +1233,8 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [],
|
||||||
allow_deletion,
|
allow_deletion,
|
||||||
True, True, False,
|
True, True, False,
|
||||||
send_threads, False,
|
send_threads, False,
|
||||||
watermark_width_percent)
|
watermark_width_percent,
|
||||||
|
watermark_position)
|
||||||
|
|
||||||
|
|
||||||
def create_server_group(path: str, domain: str, port: int,
|
def create_server_group(path: str, domain: str, port: int,
|
||||||
|
@ -1293,7 +1299,8 @@ def create_server_group(path: str, domain: str, port: int,
|
||||||
public_replies_unlisted = False
|
public_replies_unlisted = False
|
||||||
no_of_books = 10
|
no_of_books = 10
|
||||||
accounts_data_dir = None
|
accounts_data_dir = None
|
||||||
watermark_width_percent = 20
|
watermark_width_percent = 30
|
||||||
|
watermark_position = 'east'
|
||||||
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,
|
||||||
|
@ -1325,7 +1332,8 @@ def create_server_group(path: str, domain: str, port: int,
|
||||||
proxy_type, max_replies,
|
proxy_type, max_replies,
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
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