1
0
Fork 0
isopod.cool/stuff/webpkiller/webpkiller.py
2024-09-30 13:29:41 -06:00

27 lines
No EOL
690 B
Python
Executable file

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))