aboutsummaryrefslogtreecommitdiff
path: root/stuff/webpkiller/webpkiller.py
blob: 0153ff7cbbbd181225cf3dfa9e0078e6c27bd88c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import PIL as pillow
from PIL import Image
import subprocess, os, platform, sys

infile = sys.argv[len(sys.argv)-1]
outfile = infile[:infile.rfind('.')] + ".png"

if(os.path.exists(infile) == False):
    print("File %s not found. Aborting..." %infile)
    exit()

if(os.path.exists(outfile)):
    print("File %s already exists. Aborting..." %outfile)
    exit()

im = Image.open(infile)

im.save(outfile)

os.remove(infile)

if(platform.system() == 'Darwin'):       # macOS
    subprocess.call(('open', outfile))
elif(platform.system() == 'Windows'):    # Windows
    os.startfile(outfile)
else:                                    # linux variants
    subprocess.call(('xdg-open', outfile))