mirror of https://gitlab.com/bashrc2/epicyon
Apply dithering to shared item images
parent
67427f215f
commit
3e304dca55
|
|
@ -1911,8 +1911,8 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||||
|
|
||||||
# Note: a .temp extension is used here so that at no time is
|
# Note: a .temp extension is used here so that at no time is
|
||||||
# an image with metadata publicly exposed, even for a few mS
|
# an image with metadata publicly exposed, even for a few mS
|
||||||
filename_base = \
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
acct_dir(base_dir, nickname, domain) + '/upload.temp'
|
filename_base = account_dir + '/upload.temp'
|
||||||
|
|
||||||
filename, attachment_media_type = \
|
filename, attachment_media_type = \
|
||||||
save_media_in_form_post(media_bytes, debug, filename_base)
|
save_media_in_form_post(media_bytes, debug, filename_base)
|
||||||
|
|
@ -1925,8 +1925,10 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||||
exif_json: list[dict] = []
|
exif_json: list[dict] = []
|
||||||
if filename:
|
if filename:
|
||||||
if is_image_file(filename):
|
if is_image_file(filename):
|
||||||
|
dither_filename = account_dir + '/.ditherImage'
|
||||||
|
apply_dithering = is_a_file(dither_filename)
|
||||||
# convert to low bandwidth if needed
|
# convert to low bandwidth if needed
|
||||||
if low_bandwidth:
|
if low_bandwidth or apply_dithering:
|
||||||
print('Converting to low bandwidth ' + filename)
|
print('Converting to low bandwidth ' + filename)
|
||||||
convert_image_to_low_bandwidth(filename)
|
convert_image_to_low_bandwidth(filename)
|
||||||
backup_filename = filename + '.backup'
|
backup_filename = filename + '.backup'
|
||||||
|
|
|
||||||
|
|
@ -496,7 +496,7 @@ def convert_image_to_low_bandwidth(image_filename: str) -> None:
|
||||||
|
|
||||||
cmd = \
|
cmd = \
|
||||||
"convert \"" + safe_system_string(image_filename) + "\" " + \
|
"convert \"" + safe_system_string(image_filename) + "\" " + \
|
||||||
"-resize 800 -set option:distort:viewport '%wx%h+0+0' " + \
|
"-resize 1000 -set option:distort:viewport '%wx%h+0+0' " + \
|
||||||
'-colorspace CMYK -separate null: \\( -size 2x2 xc: ' + \
|
'-colorspace CMYK -separate null: \\( -size 2x2 xc: ' + \
|
||||||
'\\( +clone -negate \\) +append \\( +clone -negate \\) ' + \
|
'\\( +clone -negate \\) +append \\( +clone -negate \\) ' + \
|
||||||
'-append \\) -virtual-pixel tile -filter gaussian ' + \
|
'-append \\) -virtual-pixel tile -filter gaussian ' + \
|
||||||
|
|
|
||||||
|
|
@ -352,8 +352,8 @@ def add_share(base_dir: str,
|
||||||
system_language):
|
system_language):
|
||||||
print('Shared item was filtered due to content')
|
print('Shared item was filtered due to content')
|
||||||
return
|
return
|
||||||
shares_filename = \
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
acct_dir(base_dir, nickname, domain) + '/' + shares_file_type + '.json'
|
shares_filename = account_dir + '/' + shares_file_type + '.json'
|
||||||
shares_json = {}
|
shares_json = {}
|
||||||
if is_a_file(shares_filename):
|
if is_a_file(shares_filename):
|
||||||
shares_json = load_json(shares_filename)
|
shares_json = load_json(shares_filename)
|
||||||
|
|
@ -393,10 +393,12 @@ def add_share(base_dir: str,
|
||||||
makedir(base_dir + '/sharefiles/' + nickname)
|
makedir(base_dir + '/sharefiles/' + nickname)
|
||||||
item_idfile = base_dir + '/sharefiles/' + nickname + '/' + item_id
|
item_idfile = base_dir + '/sharefiles/' + nickname + '/' + item_id
|
||||||
formats = get_image_extensions()
|
formats = get_image_extensions()
|
||||||
|
dither_filename = account_dir + '/.ditherImage'
|
||||||
|
apply_dithering = is_a_file(dither_filename)
|
||||||
for ext in formats:
|
for ext in formats:
|
||||||
if not image_filename.endswith('.' + ext):
|
if not image_filename.endswith('.' + ext):
|
||||||
continue
|
continue
|
||||||
if low_bandwidth:
|
if low_bandwidth or apply_dithering:
|
||||||
convert_image_to_low_bandwidth(image_filename)
|
convert_image_to_low_bandwidth(image_filename)
|
||||||
exif_json: list[dict] = []
|
exif_json: list[dict] = []
|
||||||
process_meta_data(base_dir, nickname, domain,
|
process_meta_data(base_dir, nickname, domain,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue