Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ImageMagick scripts
#!/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()
@lopezpdvn

This comment has been minimized.

Copy link
Owner Author

lopezpdvn commented Nov 19, 2019

Test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.