From 23d3577a06320520b06269472b1e492478d940bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?=
Date: Sun, 6 Oct 2013 13:53:17 +0200
Subject: [PATCH] Improved PNG output
---
KCC-Linux.ui | 2 +-
KCC-OSX.ui | 2 +-
KCC.ui | 2 +-
README.md | 3 ++-
kcc/KCC_ui.py | 4 ++--
kcc/KCC_ui_linux.py | 4 ++--
kcc/KCC_ui_osx.py | 4 ++--
kcc/comic2ebook.py | 2 +-
kcc/image.py | 6 ++++--
9 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/KCC-Linux.ui b/KCC-Linux.ui
index d14ac80..3ec09de 100644
--- a/KCC-Linux.ui
+++ b/KCC-Linux.ui
@@ -131,7 +131,7 @@
Qt::NoFocus
- <html><head/><body><p>Create PNG files instead JPEG.</p></body></html>
+ <html><head/><body><p>Create PNG files instead JPEG.<br/>Output files will be ~33% smaller.<br/><span style=" font-weight:600;">MOBI creation will be ~3x slower.</span></p></body></html>
PNG output
diff --git a/KCC-OSX.ui b/KCC-OSX.ui
index cf266eb..4fd6d3d 100644
--- a/KCC-OSX.ui
+++ b/KCC-OSX.ui
@@ -132,7 +132,7 @@
Qt::NoFocus
- <html><head/><body><p><span style=" font-size:12pt;">Create PNG files instead JPEG.</span></p></body></html>
+ <html><head/><body><p><span style=" font-size:12pt;">Create PNG files instead JPEG.<br/>Output files will be ~33% smaller.<br/></span><span style=" font-size:12pt; font-weight:600;">MOBI creation will be ~3x slower.</span></p></body></html>
PNG output
diff --git a/KCC.ui b/KCC.ui
index beadcbd..ae920bb 100644
--- a/KCC.ui
+++ b/KCC.ui
@@ -110,7 +110,7 @@
Qt::NoFocus
- <html><head/><body><p>Create PNG files instead JPEG.</p></body></html>
+ <html><head/><body><p>Create PNG files instead JPEG.<br/>Output files will be ~33% smaller.<br/><span style=" font-weight:600;">MOBI creation will be ~3x slower.</span></p></body></html>
PNG output
diff --git a/README.md b/README.md
index 795ebd2..9f494c9 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,7 @@ You can find the latest released binary at the following links:
* Use high quality source files. **This little detail have a major impact on the final result.**
* Read tooltip of _High/Ultra quality_ option. There are many important informations there.
* When converting images smaller than device resolution remember to enable upscaling.
+* Enabling _PNG output_ can decrease size of created file up to 33%. But it also highly increase time needed to create MOBI.
* Panel View (auto zooming every part of page) can be disabled directly on Kindle. There is no KCC option to do that.
* If you're converting color images and the end result is not satisfactory, experiment with gamma correction option (check 1.0 setting first).
* Check our [wiki](https://github.com/ciromattia/kcc/wiki/Other-devices) for a list of tested Non-Kindle E-Readers.
@@ -87,7 +88,7 @@ Options:
--blackborders Disable autodetection and force black borders
--whiteborders Disable autodetection and force white borders
--forcecolor Don't convert images to grayscale
- --forcepng Create PNG files instead JPEG (For non-Kindle devices)
+ --forcepng Create PNG files instead JPEG
--gamma=GAMMA Apply gamma correction to linearize the image [Default=Auto]
--nocutpagenumbers Don't try to cut page numbering on images
--noprocessing Don't apply image preprocessing
diff --git a/kcc/KCC_ui.py b/kcc/KCC_ui.py
index 9764422..e117078 100644
--- a/kcc/KCC_ui.py
+++ b/kcc/KCC_ui.py
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'KCC.ui'
#
-# Created: Fri Oct 04 15:29:31 2013
+# Created: Sun Oct 06 13:47:45 2013
# by: PyQt4 UI code generator 4.10.3
#
# WARNING! All changes made in this file will be lost!
@@ -270,7 +270,7 @@ class Ui_KCC(object):
self.UpscaleBox.setText(_translate("KCC", "Stretch/Upscale", None))
self.WebtoonBox.setToolTip(_translate("KCC", "Enable auto-splitting of webtoons like Tower of God or Noblesse.
Pages with a low width, high height and vertical panel flow.
", None))
self.WebtoonBox.setText(_translate("KCC", "Webtoon mode", None))
- self.NoDitheringBox.setToolTip(_translate("KCC", "
Create PNG files instead JPEG.
", None))
+ self.NoDitheringBox.setToolTip(_translate("KCC", "Create PNG files instead JPEG.
Output files will be ~33% smaller.
MOBI creation will be ~3x slower.
", None))
self.NoDitheringBox.setText(_translate("KCC", "PNG output", None))
self.BorderBox.setToolTip(_translate("KCC", "Unchecked - Autodetection
Color of margins fill will be detected automatically.
Indeterminate - White
Margins will be filled with white color.
Checked - Black
Margins will be filled with black color.
", None))
self.BorderBox.setText(_translate("KCC", "W/B margins", None))
diff --git a/kcc/KCC_ui_linux.py b/kcc/KCC_ui_linux.py
index 4959319..e09eab3 100644
--- a/kcc/KCC_ui_linux.py
+++ b/kcc/KCC_ui_linux.py
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'KCC-Linux.ui'
#
-# Created: Fri Oct 04 15:29:58 2013
+# Created: Sun Oct 06 13:48:03 2013
# by: PyQt4 UI code generator 4.10.3
#
# WARNING! All changes made in this file will be lost!
@@ -339,7 +339,7 @@ class Ui_KCC(object):
self.UpscaleBox.setText(_translate("KCC", "Stretch/Upscale", None))
self.WebtoonBox.setToolTip(_translate("KCC", "Enable auto-splitting of webtoons like Tower of God or Noblesse.
Pages with a low width, high height and vertical panel flow.
", None))
self.WebtoonBox.setText(_translate("KCC", "Webtoon mode", None))
- self.NoDitheringBox.setToolTip(_translate("KCC", "Create PNG files instead JPEG.
", None))
+ self.NoDitheringBox.setToolTip(_translate("KCC", "Create PNG files instead JPEG.
Output files will be ~33% smaller.
MOBI creation will be ~3x slower.
", None))
self.NoDitheringBox.setText(_translate("KCC", "PNG output", None))
self.BorderBox.setToolTip(_translate("KCC", "Unchecked - Autodetection
Color of margins fill will be detected automatically.
Indeterminate - White
Margins will be filled with white color.
Checked - Black
Margins will be filled with black color.
", None))
self.BorderBox.setText(_translate("KCC", "W/B margins", None))
diff --git a/kcc/KCC_ui_osx.py b/kcc/KCC_ui_osx.py
index c5e53f7..18d0752 100644
--- a/kcc/KCC_ui_osx.py
+++ b/kcc/KCC_ui_osx.py
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'KCC-OSX.ui'
#
-# Created: Fri Oct 04 15:30:10 2013
+# Created: Sun Oct 06 13:48:17 2013
# by: PyQt4 UI code generator 4.10.3
#
# WARNING! All changes made in this file will be lost!
@@ -363,7 +363,7 @@ class Ui_KCC(object):
self.UpscaleBox.setText(_translate("KCC", "Stretch/Upscale", None))
self.WebtoonBox.setToolTip(_translate("KCC", "Enable auto-splitting of webtoons like Tower of God or Noblesse.
Pages with a low width, high height and vertical panel flow.
", None))
self.WebtoonBox.setText(_translate("KCC", "Webtoon mode", None))
- self.NoDitheringBox.setToolTip(_translate("KCC", "Create PNG files instead JPEG.
", None))
+ self.NoDitheringBox.setToolTip(_translate("KCC", "Create PNG files instead JPEG.
Output files will be ~33% smaller.
MOBI creation will be ~3x slower.
", None))
self.NoDitheringBox.setText(_translate("KCC", "PNG output", None))
self.BorderBox.setToolTip(_translate("KCC", "Unchecked - Autodetection
Color of margins fill will be detected automatically.
Indeterminate - White
Margins will be filled with white color.
Checked - Black
Margins will be filled with black color.
", None))
self.BorderBox.setText(_translate("KCC", "W/B margins", None))
diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py
index 8764a5f..e87c13f 100755
--- a/kcc/comic2ebook.py
+++ b/kcc/comic2ebook.py
@@ -823,7 +823,7 @@ def main(argv=None, qtGUI=None):
processingOptions.add_option("--forcecolor", action="store_true", dest="forcecolor", default=False,
help="Don't convert images to grayscale")
processingOptions.add_option("--forcepng", action="store_true", dest="forcepng", default=False,
- help="Create PNG files instead JPEG (For non-Kindle devices)")
+ help="Create PNG files instead JPEG")
processingOptions.add_option("--gamma", type="float", dest="gamma", default="0.0",
help="Apply gamma correction to linearize the image [Default=Auto]")
processingOptions.add_option("--nocutpagenumbers", action="store_false", dest="cutpagenumbers", default=True,
diff --git a/kcc/image.py b/kcc/image.py
index 97c97b8..8388802 100755
--- a/kcc/image.py
+++ b/kcc/image.py
@@ -183,9 +183,11 @@ class ComicPage:
if self.border:
suffix += "_kccx" + str(self.border[0]) + "_kccy" + str(self.border[1])
if forcepng:
- self.image.save(os.path.join(targetdir, os.path.splitext(self.filename)[0] + suffix + ".png"), "PNG")
+ self.image.save(os.path.join(targetdir, os.path.splitext(self.filename)[0] + suffix + ".png"), "PNG",
+ optimize=1)
else:
- self.image.save(os.path.join(targetdir, os.path.splitext(self.filename)[0] + suffix + ".jpg"), "JPEG")
+ self.image.save(os.path.join(targetdir, os.path.splitext(self.filename)[0] + suffix + ".jpg"), "JPEG",
+ optimize=1)
except IOError as e:
raise RuntimeError('Cannot write image in directory %s: %s' % (targetdir, e))