From cda271f2d9d05cdddef3581329d0caf98d5aa665 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 21 Dec 2015 21:08:50 +0530 Subject: [PATCH] ... --- src/calibre/utils/img.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/img.py b/src/calibre/utils/img.py index 0ec208cc36..fd564666c3 100644 --- a/src/calibre/utils/img.py +++ b/src/calibre/utils/img.py @@ -66,7 +66,10 @@ def scale_image(data, width=60, height=80, compression_quality=70, as_png=False, def run_optimizer(file_path, cmd, as_filter=False, input_data=None): file_path = os.path.abspath(file_path) cwd = os.path.dirname(file_path) - fd, outfile = tempfile.mkstemp(dir=cwd) + ext = os.path.splitext(file_path)[1] + if not ext or len(ext) > 10 or not ext.startswith('.'): + ext = '.jpg' + fd, outfile = tempfile.mkstemp(dir=cwd, suffix=ext) try: if as_filter: outf = os.fdopen(fd, 'wb')