Last active
May 26, 2018 15:39
-
-
Save Omochin/94e47189a00b77ca0f73d0c5a1b59953 to your computer and use it in GitHub Desktop.
Need 'pip install pillow'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from PIL import Image | |
def main(): | |
input_path = './a' | |
output_path = './b' | |
quality = 30 | |
if not os.path.isdir(output_path): | |
os.mkdir(output_path) | |
for filename in os.listdir(input_path): | |
base, ext = os.path.splitext(filename) | |
if ext == '.png': | |
save_path = os.path.join(output_path, base + '.jpg') | |
input_image = Image.open(os.path.join(input_path, filename)) | |
input_image.convert('RGB').save(save_path, quality=quality) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment