Created
August 12, 2016 05:22
-
-
Save lopezpdvn/37c50a64aec0cbd8b538fc38a786db2a to your computer and use it in GitHub Desktop.
ImageMagick scripts
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
#!/usr/bin/env python3 | |
# coding=utf-8 | |
import sys | |
from os import walk | |
from os.path import join | |
from subprocess import Popen | |
ROOTFP = sys.argv[1] | |
PERCENTAGE = sys.argv[2] | |
CONVERT_CMD = ('mogrify', '-verbose', '-resize', PERCENTAGE+'%') | |
def get_images(rootfp): | |
for relpath, dirs, files in walk(rootfp): | |
for f in files: | |
yield join(relpath, f) | |
for i in get_images(sys.argv[1]): | |
cmd = tuple(CONVERT_CMD + (i,)) | |
with Popen(cmd) as proc: | |
proc.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test