mirror of
https://github.com/Xevion/sharex-quickzoom.git
synced 2025-12-08 12:08:28 -06:00
clean.py cleansing service
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
# Custom Additions
|
||||
/temp/
|
||||
*.png
|
||||
!/screenshot.png
|
||||
*.jpg
|
||||
|
||||
26
clean.py
Normal file
26
clean.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import os, sys
|
||||
|
||||
basepath = sys.path[0]
|
||||
blacklist = [
|
||||
'clean.py',
|
||||
'main.py',
|
||||
'LICENSE',
|
||||
'output.jpg',
|
||||
'screenshot.png',
|
||||
'README.md',
|
||||
'.git',
|
||||
'.gitignore',
|
||||
]
|
||||
|
||||
_log = []
|
||||
print('DELETED SEQUENCE STARTED')
|
||||
for file in os.listdir(basepath):
|
||||
filepath = os.path.join(basepath, file)
|
||||
if file not in blacklist:
|
||||
_log.append('DELETED: \'{}\''.format(filepath))
|
||||
os.remove(filepath)
|
||||
else:
|
||||
pass
|
||||
# print('IGNORED: \'{}\''.format(filepath))
|
||||
print('\n'.join(_log))
|
||||
print(f'FINISHED DELETED {len(_log)} FILES')
|
||||
28
main.py
28
main.py
@@ -1,4 +1,4 @@
|
||||
import os, sys, time, argparse
|
||||
import os, sys, time, argparse, subprocess
|
||||
|
||||
# Simple tester for testing whether a file exists.
|
||||
# StackOverflow https://stackoverflow.com/a/51212150/6912830
|
||||
@@ -9,8 +9,26 @@ def file_path(string):
|
||||
raise NotADirectoryError(string)
|
||||
|
||||
# Argparser
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('path', metavar='PATH', type=file_path, help='the full path to the file in question')
|
||||
args = parser.parse_args()
|
||||
# parser = argparse.ArgumentParser()
|
||||
# parser.add_argument('path', metavar='PATH', type=file_path, help='the full path to the file in question')
|
||||
# args = parser.parse_args()
|
||||
|
||||
print(args.path)
|
||||
# print(args.path)
|
||||
|
||||
# Image Processing
|
||||
command_args = "5x0+90+450"
|
||||
|
||||
base_path = sys.path[0]
|
||||
blur_map = os.path.join(base_path, 'blur_map_polar.jpg')
|
||||
input_path = os.path.join(base_path, 'blur_radial.jpg')
|
||||
output_path = os.path.join(base_path, 'output.jpg')
|
||||
|
||||
for path in [base_path, blur_map, input_path, output_path]:
|
||||
if not os.path.exists(path):
|
||||
raise Exception('Invalid File Name')
|
||||
|
||||
|
||||
# command = ['magick convert', input_path, blur_map, '-compose blur', '-define', 'compose:args=' + command_args, '-composite ', output_path]
|
||||
command = 'magick convert {} {} -compose blur -define compose:args={} -composite {}'.format(input_path, blur_map, command_args, output_path)
|
||||
print(command)
|
||||
subprocess.run(command.split(' '))
|
||||
Reference in New Issue
Block a user