Last active
January 11, 2016 19:20
-
-
Save paulocheque/f68ebe3b56168f8f5ded to your computer and use it in GitHub Desktop.
image processing
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 os import listdir | |
from os.path import isfile, join | |
from invoke import run, task | |
dirpath = './mypath' | |
@task | |
def resize(): | |
#http://www.imagemagick.org/Usage/resize/#resize | |
for filename in listdir(dirpath): | |
if isfile(join(dirpath, filename)): | |
prefix, extension = os.path.splitext(filename) | |
if extension in ('.jpg', '.jpeg', '.png', '.gif'): | |
run('convert {} -resize 200x200 {}_200x200{}'.format(os.path.join(dirpath, filename), os.path.join(dirpath, prefix), extension)) | |
resize() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment