mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Edit book: Compress images tool: Do not mark the book as changed if no images could be further compressed.
This commit is contained in:
parent
eb0fca8cf7
commit
c1ef1a8557
@ -91,10 +91,13 @@ def compress_images(container, report=None, names=None, jpeg_quality=None, progr
|
|||||||
[Worker(abort, 'CompressImage%d' % i, queue, results, container, jpeg_quality, pc) for i in xrange(min(detect_ncpus(), len(images)))]
|
[Worker(abort, 'CompressImage%d' % i, queue, results, container, jpeg_quality, pc) for i in xrange(min(detect_ncpus(), len(images)))]
|
||||||
queue.join()
|
queue.join()
|
||||||
before_total = after_total = 0
|
before_total = after_total = 0
|
||||||
|
changed = False
|
||||||
for name, (ok, res) in results.iteritems():
|
for name, (ok, res) in results.iteritems():
|
||||||
name = force_unicode(name, filesystem_encoding)
|
name = force_unicode(name, filesystem_encoding)
|
||||||
if ok:
|
if ok:
|
||||||
before, after = res
|
before, after = res
|
||||||
|
if before != after:
|
||||||
|
changed = True
|
||||||
before_total += before
|
before_total += before
|
||||||
after_total += after
|
after_total += after
|
||||||
if report:
|
if report:
|
||||||
@ -107,10 +110,10 @@ def compress_images(container, report=None, names=None, jpeg_quality=None, progr
|
|||||||
report(_('Failed to process {0} with error:').format(name))
|
report(_('Failed to process {0} with error:').format(name))
|
||||||
report(res)
|
report(res)
|
||||||
if report:
|
if report:
|
||||||
if before_total > 0:
|
if changed:
|
||||||
report('')
|
report('')
|
||||||
report(_('Total image filesize reduced from {0} to {1} [{2:.1%} reduction]').format(
|
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))
|
human_readable(before_total), human_readable(after_total), (before_total - after_total)/before_total))
|
||||||
else:
|
else:
|
||||||
report(_('Images are already fully optimized'))
|
report(_('Images are already fully optimized'))
|
||||||
return before_total > 0, results
|
return changed, results
|
||||||
|
Loading…
x
Reference in New Issue
Block a user