Image compression: If the compression tools return a zero byte image ignore it and use the original image

This commit is contained in:
Kovid Goyal 2015-12-11 18:38:45 +05:30
parent 6abc3a55ca
commit 4d78cc9f1a

View File

@ -105,6 +105,12 @@ def run_optimizer(file_path, cmd, as_filter=False, input_data=None):
if p.wait() != 0: if p.wait() != 0:
return raw return raw
else: else:
try:
sz = os.path.getsize(outfile)
except EnvironmentError:
sz = 0
if sz < 1:
return raw
shutil.copystat(file_path, outfile) shutil.copystat(file_path, outfile)
atomic_rename(outfile, file_path) atomic_rename(outfile, file_path)
finally: finally: