Merge pull request #4 from samholt/master

feat: Add memlimit arg
This commit is contained in:
Andros Fenollosa 2020-07-15 11:47:50 +02:00 committed by GitHub
commit 3fb4fac647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,8 +20,13 @@ LIMIT_QUALITY = 84
quality=LIMIT_QUALITY
)
)
@click.option(
'--memlimit',
default=28000,
help='Memory limit in MB. Guetzli will fail if unable to stay under the limit. Default is 28000 MB'
)
@click.argument('folder', type=click.Path(exists=True))
def run(quality, folder):
def run(quality, memlimit, folder):
for dirpath, dirnames, files in walk(folder):
for name in files:
url = path.join(dirpath, name)
@ -36,7 +41,10 @@ def run(quality, folder):
except:
pass
# Execute guetzli
call(['guetzli', '--quality', str(quality), url, url_out])
args = ['guetzli', '--quality',
str(quality), '--memlimit', str(memlimit), url, url_out]
print(' '.join(args))
call(args)
# Print your have saved
size_source = path.getsize(url)
try: