mirror of https://gitlab.com/bashrc2/epicyon
Improve dithering
parent
0f92154be0
commit
80ce1af995
25
src/media.py
25
src/media.py
|
|
@ -482,17 +482,32 @@ def get_music_metadata(filename: str) -> {}:
|
||||||
def convert_image_to_low_bandwidth(image_filename: str) -> None:
|
def convert_image_to_low_bandwidth(image_filename: str) -> None:
|
||||||
"""Converts an image to a low bandwidth version
|
"""Converts an image to a low bandwidth version
|
||||||
"""
|
"""
|
||||||
low_bandwidth_filename = image_filename + '.low'
|
low_bandwidth_filename = safe_system_string(image_filename + '.low')
|
||||||
if is_a_file(low_bandwidth_filename):
|
if is_a_file(low_bandwidth_filename):
|
||||||
erase_file(low_bandwidth_filename,
|
erase_file(low_bandwidth_filename,
|
||||||
'EX: convert_image_to_low_bandwidth unable to delete ' +
|
'EX: convert_image_to_low_bandwidth unable to delete ' +
|
||||||
low_bandwidth_filename)
|
low_bandwidth_filename)
|
||||||
|
|
||||||
|
# cmd = \
|
||||||
|
# '/usr/bin/convert +noise Multiplicative ' + \
|
||||||
|
# '-evaluate median 10% -dither Floyd-Steinberg ' + \
|
||||||
|
# '-monochrome ' + safe_system_string(image_filename) + \
|
||||||
|
# ' ' + low_bandwidth_filename
|
||||||
|
|
||||||
cmd = \
|
cmd = \
|
||||||
'/usr/bin/convert +noise Multiplicative ' + \
|
"convert \"" + safe_system_string(image_filename) + "\" " + \
|
||||||
'-evaluate median 10% -dither Floyd-Steinberg ' + \
|
"-resize 800 -set option:distort:viewport '%wx%h+0+0' " + \
|
||||||
'-monochrome ' + safe_system_string(image_filename) + \
|
'-colorspace CMYK -separate null: \\( -size 2x2 xc: ' + \
|
||||||
' ' + safe_system_string(low_bandwidth_filename)
|
'\\( +clone -negate \\) +append \\( +clone -negate \\) ' + \
|
||||||
|
'-append \\) -virtual-pixel tile -filter gaussian ' + \
|
||||||
|
'\\( +clone -distort SRT 2,0 \\) ' + \
|
||||||
|
'+swap \\( +clone -distort SRT 2,15 \\) ' + \
|
||||||
|
'+swap \\( +clone -distort SRT 2,45 \\) ' + \
|
||||||
|
'+swap \\( +clone -distort SRT 2,75 \\) ' + \
|
||||||
|
'+swap +delete -compose Overlay -layers composite ' + \
|
||||||
|
'-colors 2 -set colorspace CMYK -combine "' + \
|
||||||
|
low_bandwidth_filename + '"'
|
||||||
|
|
||||||
print('Low bandwidth image conversion: ' + cmd)
|
print('Low bandwidth image conversion: ' + cmd)
|
||||||
subprocess.call(cmd, shell=True)
|
subprocess.call(cmd, shell=True)
|
||||||
# wait for conversion to happen
|
# wait for conversion to happen
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue