Skip to content

Instantly share code, notes, and snippets.

@quantumchuckles
Created September 8, 2021 07:47
Show Gist options
  • Select an option

  • Save quantumchuckles/aacdcdb1f9a4eb0c51852b42001cd751 to your computer and use it in GitHub Desktop.

Select an option

Save quantumchuckles/aacdcdb1f9a4eb0c51852b42001cd751 to your computer and use it in GitHub Desktop.
image convertion jpg to png using PILLOW fork
import sys
import os
from PIL import Image
path = sys.argv[1]
directory = sys.argv[2]
if not os.path.exists(directory):
os.makedirs(directory)
for filename in os.listdir(path):
clean_name = os.path.splitext(filename)[0]
img = Image.open(f'{path}{filename}')
#added the / in case user doesn't enter it. You may want to check for this and add or remover it.
img.save(f'{directory}/{clean_name}.png', 'png')
print('all done!')
@quantumchuckles

quantumchuckles commented Sep 8, 2021

Copy link
Copy Markdown
Author

python3 JPGtoPNGconverter.py dir to the original image folder new folder where converted images are placed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment