1
0
mirror of https://github.com/ciromattia/kcc synced 2026-07-01 02:25:29 +00:00

Gamma auto mode is now even more automatic

This commit is contained in:
Paweł Jastrzębski
2013-12-04 18:30:19 +01:00
parent af263073b5
commit 572e1422bf
9 changed files with 32 additions and 30 deletions
+1 -1
View File
@@ -372,6 +372,7 @@ class WorkerThread(QtCore.QThread):
if GUI.WebtoonBox.isChecked():
argv.append("--webtoon")
if float(GUI.GammaValue) > 0.09:
# noinspection PyTypeChecker
argv.append("--gamma=" + GUI.GammaValue)
if str(GUI.FormatBox.currentText()) == 'CBZ':
argv.append("--cbz-output")
@@ -715,7 +716,6 @@ class KCCGUI(KCC_ui.Ui_KCC):
GUI.QualityBox.setChecked(False)
GUI.MangaBox.setEnabled(False)
GUI.MangaBox.setChecked(False)
self.addMessage('If images will be too dark after conversion: Set <i>Gamma</i> to 1.0.', 'info')
else:
if not GUI.ProcessingBox.isChecked():
GUI.NoRotateBox.setEnabled(True)
+1 -3
View File
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'KCC.ui'
#
# Created: Tue Nov 12 14:31:48 2013
# Created: Wed Dec 04 18:28:13 2013
# by: PyQt4 UI code generator 4.10.3
#
# WARNING! All changes made in this file will be lost!
@@ -305,9 +305,7 @@ class Ui_KCC(object):
self.RotateBox.setText(_translate("KCC", "Horizontal mode", None))
self.BasicModeButton.setText(_translate("KCC", "Basic", None))
self.AdvModeButton.setText(_translate("KCC", "Advanced", None))
self.GammaLabel.setToolTip(_translate("KCC", "When converting color images setting this option to 1.0 MIGHT improve readability.", None))
self.GammaLabel.setText(_translate("KCC", "Gamma: Auto", None))
self.GammaSlider.setToolTip(_translate("KCC", "<html><head/><body><p>When converting color images setting this option to 1.0 <span style=\" font-weight:600;\">might</span> improve readability.</p></body></html>", None))
self.ColorBox.setToolTip(_translate("KCC", "Do not convert images to grayscale.", None))
self.ColorBox.setText(_translate("KCC", "Color mode", None))
self.wLabel.setToolTip(_translate("KCC", "Resolution of target device.", None))
+1 -3
View File
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'KCC-Linux.ui'
#
# Created: Tue Nov 12 14:32:11 2013
# Created: Wed Dec 04 18:27:52 2013
# by: PyQt4 UI code generator 4.10.3
#
# WARNING! All changes made in this file will be lost!
@@ -374,9 +374,7 @@ class Ui_KCC(object):
self.RotateBox.setText(_translate("KCC", "Horizontal mode", None))
self.BasicModeButton.setText(_translate("KCC", "Basic", None))
self.AdvModeButton.setText(_translate("KCC", "Advanced", None))
self.GammaLabel.setToolTip(_translate("KCC", "<html><head/><body><p>When converting color images setting this option to 1.0 <span style=\" font-weight:600;\">might</span> improve readability.</p></body></html>", None))
self.GammaLabel.setText(_translate("KCC", "Gamma: Auto", None))
self.GammaSlider.setToolTip(_translate("KCC", "<html><head/><body><p>When converting color images setting this option to 1.0 <span style=\" font-weight:600;\">might</span> improve readability.</p></body></html>", None))
self.ColorBox.setToolTip(_translate("KCC", "Do not convert images to grayscale.", None))
self.ColorBox.setText(_translate("KCC", "Color mode", None))
self.wLabel.setToolTip(_translate("KCC", "Resolution of target device.", None))
+1 -3
View File
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'KCC-OSX.ui'
#
# Created: Tue Nov 12 14:31:59 2013
# Created: Wed Dec 04 18:28:04 2013
# by: PyQt4 UI code generator 4.10.3
#
# WARNING! All changes made in this file will be lost!
@@ -392,9 +392,7 @@ class Ui_KCC(object):
self.RotateBox.setText(_translate("KCC", "Horizontal mode", None))
self.BasicModeButton.setText(_translate("KCC", "Basic", None))
self.AdvModeButton.setText(_translate("KCC", "Advanced", None))
self.GammaLabel.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-size:12pt;\">When converting color images setting this option to 1.0 </span><span style=\" font-size:12pt; font-weight:600;\">might</span><span style=\" font-size:12pt;\"> improve readability.</span></p></body></html>", None))
self.GammaLabel.setText(_translate("KCC", "Gamma: Auto", None))
self.GammaSlider.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-size:12pt;\">When converting color images setting this option to 1.0 </span><span style=\" font-size:12pt; font-weight:600;\">might</span><span style=\" font-size:12pt;\"> improve readability.</span></p></body></html>", None))
self.ColorBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-size:12pt;\">Do not convert images to grayscale.</span></p></body></html>", None))
self.ColorBox.setText(_translate("KCC", "Color mode", None))
self.wLabel.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-size:12pt;\">Resolution of target device.</span></p></body></html>", None))
+28 -1
View File
@@ -214,6 +214,8 @@ class ComicPage:
def optimizeImage(self, gamma):
if gamma < 0.1:
gamma = self.gamma
if self.gamma != 1.0 and self.isImageColor(self.image):
gamma = 1.0
if gamma == 1.0:
self.image = ImageOps.autocontrast(self.image)
else:
@@ -519,4 +521,29 @@ class ComicPage:
if fill > 0:
self.fill = 'black'
else:
self.fill = 'white'
self.fill = 'white'
def isImageColor(self, image):
v = ImageStat.Stat(image).var
isMonochromatic = reduce(lambda x, y: x and y < 0.005, v, True)
if isMonochromatic:
# Monochromatic
return False
else:
if len(v) == 3:
maxmin = abs(max(v) - min(v))
if maxmin > 1000:
# Color
return True
elif maxmin > 100:
# Probably color
return True
else:
# Grayscale
return False
elif len(v) == 1:
# Black and white
return False
else:
# Detection failed
return False