From dbb14e37fac91bb9dc39ef37c35a829dea14342a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Fri, 21 Jun 2013 13:23:14 +0200 Subject: [PATCH 1/5] Updated setup.py - OSX use py2app again --- other/qt.conf | 2 ++ setup.py | 42 +++++++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 other/qt.conf diff --git a/other/qt.conf b/other/qt.conf new file mode 100644 index 0000000..bbb0228 --- /dev/null +++ b/other/qt.conf @@ -0,0 +1,2 @@ +[Paths] +Plugins = DumbHackThatFixPY2APP diff --git a/setup.py b/setup.py index ad45473..1f04416 100644 --- a/setup.py +++ b/setup.py @@ -2,35 +2,46 @@ cx_Freeze build script for KCC. Usage (Mac OS X): - python setup.py bdist_mac + python setup.py py2app Usage (Windows): python setup.py build """ from sys import platform -from cx_Freeze import setup, Executable NAME = "KindleComicConverter" VERSION = "3.0" MAIN = "kcc.py" -includefiles = ['LICENSE.txt'] -includes = [] -excludes = [] - if platform == "darwin": + from setuptools import setup extra_options = dict( - options={"build_exe": {"include_files": includefiles, "excludes": excludes, "compressed": True}, - "bdist_mac": {"iconfile": "icons/comic2ebook.icns"}}, - executables=[Executable(MAIN, - copyDependentFiles=True, - appendScriptToExe=True, - appendScriptToLibrary=False, - compress=True)]) + setup_requires=['py2app'], + app=[MAIN], + options=dict( + py2app=dict( + argv_emulation=True, + iconfile='icons/comic2ebook.icns', + includes=['PIL', 'sip', 'PyQt4', 'PyQt4.QtCore', 'PyQt4.QtGui'], + resources=['other/qt.conf', 'LICENSE.txt'], + plist=dict( + CFBundleName=NAME, + CFBundleShortVersionString=VERSION, + CFBundleGetInfoString=NAME + " " + VERSION + + ", written 2012-2013 by Ciro Mattia Gonano and Pawel Jastrzebski", + CFBundleExecutable=NAME, + CFBundleIdentifier='com.github.ciromattia.kcc', + CFBundleSignature='dplt', + NSHumanReadableCopyright='ISC License (ISCL)' + ) + ) + ) + ) elif platform == "win32": + from cx_Freeze import setup, Executable base = "Win32GUI" extra_options = dict( - options={"build_exe": {"include_files": includefiles, "excludes": excludes, "compressed": True}}, + options={"build_exe": {"include_files": ['LICENSE.txt'], "compressed": True}}, executables=[Executable(MAIN, base=base, targetName="KCC.exe", @@ -40,8 +51,9 @@ elif platform == "win32": appendScriptToLibrary=False, compress=True)]) else: + from cx_Freeze import setup, Executable extra_options = dict( - options={"build_exe": {"include_files": includefiles, "excludes": excludes, "compressed": True}}, + options={"build_exe": {"include_files": ['LICENSE.txt'], "compressed": True}}, executables=[Executable(MAIN, icon="icons/comic2ebook.png", copyDependentFiles=True, From 3e117f46d5f6985126a390d3b9a0194823662014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Fri, 21 Jun 2013 14:35:06 +0200 Subject: [PATCH 2/5] Added KindleGen version check --- README.md | 2 +- kcc/KCC_gui.py | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index aad8ec0..6f81943 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ In the meanwhile you can download [version 2.9](http://kcc.vulturis.eu/OSX/Kindl - PDF *(Extracting only contained JPG images)* ## OPTIONAL REQUIREMENTS -- [KindleGen](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211) v2.8+ in a directory reachable by your _PATH_ or in _KCC_ directory *(For .mobi generation)* +- [KindleGen](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211) v2.9+ in a directory reachable by your _PATH_ or in _KCC_ directory *(For .mobi generation)* - [UnRAR](http://www.rarlab.com/download.htm) *(For CBR/RAR support)* ### For compiling/running from source: diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 8f92482..4d8159f 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -30,9 +30,10 @@ import urllib2 import comic2ebook import kindlestrip from image import ProfileData -from subprocess import call, STDOUT, PIPE +from subprocess import call, Popen, STDOUT, PIPE from PyQt4 import QtGui, QtCore from xml.dom.minidom import parse +from string import split class Icons: @@ -415,8 +416,22 @@ class Ui_KCC(object): self.addMessage('Welcome!', 'info') self.addMessage('Remember: All options have additional informations in tooltips.', 'info') if call('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True) == 0: - self.KindleGen = True - formats = ['MOBI', 'EPUB', 'CBZ'] + versionCheck = Popen('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True) + for line in versionCheck.stdout: + if "Amazon kindlegen" in line: + versionCheck = line.split('V')[1].split(' ')[0] + if tuple(map(int, (versionCheck.split(".")))) >= tuple(map(int, ('2.9'.split(".")))): + versionCheck = True + else: + versionCheck = False + break + if versionCheck: + self.KindleGen = True + formats = ['MOBI', 'EPUB', 'CBZ'] + else: + self.KindleGen = False + formats = ['EPUB', 'CBZ'] + self.addMessage('KindleGen is outdated! Creating MOBI files is disabled.', 'warning') else: self.KindleGen = False formats = ['EPUB', 'CBZ'] From 02d1fe308df0ca0b76080153c74d7bf0cbcb612d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Fri, 21 Jun 2013 18:30:11 +0200 Subject: [PATCH 3/5] Small cleanup --- kcc/KCC_gui.py | 1 - kcc/KCC_rc.py | 2 +- kcc/KCC_ui.py | 2 +- kcc/KCC_ui_osx.py | 2 +- kcc/comic2ebook.py | 8 +++----- kcc/image.py | 1 + 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 4d8159f..5f91198 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -33,7 +33,6 @@ from image import ProfileData from subprocess import call, Popen, STDOUT, PIPE from PyQt4 import QtGui, QtCore from xml.dom.minidom import parse -from string import split class Icons: diff --git a/kcc/KCC_rc.py b/kcc/KCC_rc.py index 0fa5393..c25c54d 100644 --- a/kcc/KCC_rc.py +++ b/kcc/KCC_rc.py @@ -2,7 +2,7 @@ # Resource object code # -# Created: Śr 19. cze 10:35:51 2013 +# Created: Pt 21. cze 18:23:49 2013 # by: The Resource Compiler for PyQt (Qt v4.8.4) # # WARNING! All changes made in this file will be lost! diff --git a/kcc/KCC_ui.py b/kcc/KCC_ui.py index d89fea3..7d3baba 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: Wed Jun 19 11:39:49 2013 +# Created: Fri Jun 21 18:23:19 2013 # by: PyQt4 UI code generator 4.10.1 # # WARNING! All changes made in this file will be lost! diff --git a/kcc/KCC_ui_osx.py b/kcc/KCC_ui_osx.py index 14fa220..8f218c1 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: Wed Jun 19 13:56:35 2013 +# Created: Fri Jun 21 18:23:35 2013 # by: PyQt4 UI code generator 4.10.1 # # WARNING! All changes made in this file will be lost! diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index a822df4..e8ba199 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -627,10 +627,8 @@ def getWorkFolder(afile): def slugify(value): - """ - Normalizes string, converts to lowercase, removes non-alpha characters, - and converts spaces to hyphens. - """ + # Normalizes string, converts to lowercase, removes non-alpha characters, + # and converts spaces to hyphens. import unicodedata value = unicodedata.normalize('NFKD', unicode(value, 'latin1')).encode('ascii', 'ignore') value = re.sub('[^\w\s\.-]', '', value).strip().lower() @@ -794,7 +792,7 @@ def checkOptions(): options.panelview = True options.landscapemode = False else: - # Virtual Panel View + # Virtual Panel View or Panel View disabled options.panelview = False # Older Kindle don't need higher resolution files due lack of Panel View. # Kindle Fire family have very high resolution. Bigger images are not needed. diff --git a/kcc/image.py b/kcc/image.py index 7b39f29..2874c1c 100755 --- a/kcc/image.py +++ b/kcc/image.py @@ -181,6 +181,7 @@ class ComicPage: size = (self.size[0], self.size[1]) else: size = (self.panelviewsize[0], self.panelviewsize[1]) + # Kindle Paperwhite - Force upscale of splited pages to increase readability if isSplit and landscapeMode: upscale = True if self.image.size[0] <= self.size[0] and self.image.size[1] <= self.size[1]: From 57bfd6b968b501cc6f114c5dc6fdb5a6ef3a9205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Sat, 22 Jun 2013 20:02:12 +0200 Subject: [PATCH 4/5] Updated README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6f81943..4c3c53a 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,8 @@ You can find the latest released binary at the following links: - **OS X:** [http://kcc.vulturis.eu/OSX/](http://kcc.vulturis.eu/OSX/) - **Linux:** Just download sourcecode and launch: `python kcc.py` -_It has been reported by a couple of users 2.10 crashing on OSX at start. -If it happens to you please append your message to [Issue #52](https://github.com/ciromattia/kcc/issues/52). -In the meanwhile you can download [version 2.9](http://kcc.vulturis.eu/OSX/KindleComicConverter_osx_2.9.zip)._ +_It has been reported by a couple of users that version 2.10 crashing on OSX at start. We don't know if that issue still exist in version 3.0. +If it happens to you please append your message to [Issue #52](https://github.com/ciromattia/kcc/issues/52)._ ## INPUT FORMATS **KCC** can understand and convert, at the moment, the following file types: @@ -50,6 +49,7 @@ In the meanwhile you can download [version 2.9](http://kcc.vulturis.eu/OSX/Kindl ### Important tips: * 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. +* Check our [wiki](https://github.com/ciromattia/kcc/wiki/Other-devices) for a list of tested Non-Kindle E-Readers. * The first image found will be set as the comic's cover. * All files/directories will be added to EPUB in alphabetical order. * Output MOBI file should be uploaded via USB. Other methods (e.g. via Calibre) might corrupt it. From 795ccd9782714869cde08f8a79298df594a487a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Sun, 23 Jun 2013 11:20:30 +0200 Subject: [PATCH 5/5] Small tweaks --- README.md | 1 + kcc/KCC_gui.py | 2 +- kcc/comic2ebook.py | 5 +---- kcc/image.py | 10 +--------- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4c3c53a..fe8f121 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ If it happens to you please append your message to [Issue #52](https://github.co ### Important tips: * 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. * Check our [wiki](https://github.com/ciromattia/kcc/wiki/Other-devices) for a list of tested Non-Kindle E-Readers. * The first image found will be set as the comic's cover. * All files/directories will be added to EPUB in alphabetical order. diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 5f91198..9a94db4 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -73,7 +73,7 @@ class VersionThread(QtCore.QThread): except Exception: return latestVersion = XML.childNodes[0].getElementsByTagName('latest')[0].childNodes[0].toxml() - if latestVersion != __version__: + if tuple(map(int, (latestVersion.split(".")))) > tuple(map(int, (__version__.split(".")))): self.emit(QtCore.SIGNAL("addMessage"), 'New version is available!', 'warning') diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index e8ba199..30ee6e0 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -193,7 +193,6 @@ def buildNCX(dstdir, title, chapters): def buildOPF(dstdir, title, filelist, cover=None): opffile = os.path.join(dstdir, 'OEBPS', 'content.opf') - # read the first file resolution profilelabel, deviceres, palette, gamma, panelviewsize = options.profileData imgres = str(deviceres[0]) + "x" + str(deviceres[1]) if options.righttoleft: @@ -337,7 +336,7 @@ def applyImgOptimization(img, isSplit, toRight, options, overrideQuality=5): img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight, options.landscapemode, options.quality) img.optimizeImage(options.gamma) - if options.forcepng: + if options.forcepng and not options.forcecolor: img.quantizeImage() @@ -800,10 +799,8 @@ def checkOptions(): or options.profile == 'KF' or options.profile == 'KFHD' or options.profile == 'KFHD8': options.quality = 0 # Disabling grayscale conversion for Kindle Fire family. - # Forcing JPEG output. For now code can't provide color PNG files. if options.profile == 'KF' or options.profile == 'KFHD' or options.profile == 'KFHD8' or options.forcecolor: options.forcecolor = True - options.forcepng = False else: options.forcecolor = False # Mixing vertical and horizontal pages require real Panel View. diff --git a/kcc/image.py b/kcc/image.py index 2874c1c..2accc6d 100755 --- a/kcc/image.py +++ b/kcc/image.py @@ -28,14 +28,6 @@ except ImportError: exit(1) -class ImageFlags: - Orient = 1 << 0 - Resize = 1 << 1 - Frame = 1 << 2 - Quantize = 1 << 3 - Stretch = 1 << 4 - - class ProfileData: Palette4 = [ 0x00, 0x00, 0x00, @@ -181,7 +173,7 @@ class ComicPage: size = (self.size[0], self.size[1]) else: size = (self.panelviewsize[0], self.panelviewsize[1]) - # Kindle Paperwhite - Force upscale of splited pages to increase readability + # Kindle Paperwhite/Touch - Force upscale of splited pages to increase readability if isSplit and landscapeMode: upscale = True if self.image.size[0] <= self.size[0] and self.image.size[1] <= self.size[1]: