Created
August 24, 2021 22:43
-
-
Save felipecustodio/645b60abbd68cf44c0da8f85ef4b0410 to your computer and use it in GitHub Desktop.
Reduce filesize of all images in directory
This file contains hidden or 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 glob, os | |
command = """ | |
convert {original_file} \ | |
-sampling-factor 4:2:0 \ | |
-strip \ | |
-quality 85 \ | |
-interlace Plane \ | |
-gaussian-blur 0.05 \ | |
-colorspace RGB \ | |
{new_file} | |
""" | |
for file in glob.glob("*.jpeg"): | |
new_file = "converted/" + file.split(".jpeg")[0] + "_converted.jpeg" | |
print(file, new_file) | |
current_command = command.format(original_file=file, new_file=new_file) | |
stream = os.popen(current_command) | |
output = stream.read() | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment