Skip to content
Permalink
Browse files
Edit book: Compress images tool: Do not mark the book as changed if n…
…o images could be further compressed.
  • Loading branch information
kovidgoyal committed May 15, 2018
1 parent eb0fca8 commit c1ef1a85578207a1b61bd1aecddee98033eb79fc
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/calibre/ebooks/oeb/polish/images.py
@@ -91,10 +91,13 @@ def pc(name):
[Worker(abort, 'CompressImage%d' % i, queue, results, container, jpeg_quality, pc) for i in xrange(min(detect_ncpus(), len(images)))]
queue.join()
before_total = after_total = 0
changed = False
for name, (ok, res) in results.iteritems():
name = force_unicode(name, filesystem_encoding)
if ok:
before, after = res
if before != after:
changed = True
before_total += before
after_total += after
if report:
@@ -107,10 +110,10 @@ def pc(name):
report(_('Failed to process {0} with error:').format(name))
report(res)
if report:
if before_total > 0:
if changed:
report('')
report(_('Total image filesize reduced from {0} to {1} [{2:.1%} reduction]').format(
human_readable(before_total), human_readable(after_total), (before_total - after_total)/before_total))
else:
report(_('Images are already fully optimized'))
return before_total > 0, results
return changed, results

0 comments on commit c1ef1a8

Please sign in to comment.