1
0
mirror of https://github.com/ciromattia/kcc synced 2026-06-07 07:03:26 +00:00

Merge branch 'new-gui' of github.com:ciromattia/kcc into new-gui

This commit is contained in:
Ciro Mattia Gonano
2013-06-24 10:56:46 +02:00
9 changed files with 60 additions and 43 deletions
+5 -4
View File
@@ -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/) - **OS X:** [http://kcc.vulturis.eu/OSX/](http://kcc.vulturis.eu/OSX/)
- **Linux:** Just download sourcecode and launch: `python kcc.py` - **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. _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). 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)._
## INPUT FORMATS ## INPUT FORMATS
**KCC** can understand and convert, at the moment, the following file types: **KCC** can understand and convert, at the moment, the following file types:
@@ -37,7 +36,7 @@ In the meanwhile you can download [version 2.9](http://kcc.vulturis.eu/OSX/Kindl
- PDF *(Extracting only contained JPG images)* - PDF *(Extracting only contained JPG images)*
## OPTIONAL REQUIREMENTS ## 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)* - [UnRAR](http://www.rarlab.com/download.htm) *(For CBR/RAR support)*
### For compiling/running from source: ### For compiling/running from source:
@@ -50,6 +49,8 @@ In the meanwhile you can download [version 2.9](http://kcc.vulturis.eu/OSX/Kindl
### Important tips: ### Important tips:
* Use high quality source files. **This little detail have a major impact on the final result.** * 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. * 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. * The first image found will be set as the comic's cover.
* All files/directories will be added to EPUB in alphabetical order. * 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. * Output MOBI file should be uploaded via USB. Other methods (e.g. via Calibre) might corrupt it.
+18 -4
View File
@@ -30,7 +30,7 @@ import urllib2
import comic2ebook import comic2ebook
import kindlestrip import kindlestrip
from image import ProfileData from image import ProfileData
from subprocess import call, STDOUT, PIPE from subprocess import call, Popen, STDOUT, PIPE
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
from xml.dom.minidom import parse from xml.dom.minidom import parse
@@ -73,7 +73,7 @@ class VersionThread(QtCore.QThread):
except Exception: except Exception:
return return
latestVersion = XML.childNodes[0].getElementsByTagName('latest')[0].childNodes[0].toxml() 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') self.emit(QtCore.SIGNAL("addMessage"), 'New version is available!', 'warning')
@@ -415,8 +415,22 @@ class Ui_KCC(object):
self.addMessage('Welcome!', 'info') self.addMessage('Welcome!', 'info')
self.addMessage('Remember: All options have additional informations in tooltips.', 'info') self.addMessage('Remember: All options have additional informations in tooltips.', 'info')
if call('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True) == 0: if call('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True) == 0:
self.KindleGen = True versionCheck = Popen('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True)
formats = ['MOBI', 'EPUB', 'CBZ'] 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: else:
self.KindleGen = False self.KindleGen = False
formats = ['EPUB', 'CBZ'] formats = ['EPUB', 'CBZ']
+1 -1
View File
@@ -2,7 +2,7 @@
# Resource object code # 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) # by: The Resource Compiler for PyQt (Qt v4.8.4)
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
+1 -1
View File
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'KCC.ui' # 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 # by: PyQt4 UI code generator 4.10.1
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
+1 -1
View File
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'KCC-OSX.ui' # 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 # by: PyQt4 UI code generator 4.10.1
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
+4 -9
View File
@@ -193,7 +193,6 @@ def buildNCX(dstdir, title, chapters):
def buildOPF(dstdir, title, filelist, cover=None): def buildOPF(dstdir, title, filelist, cover=None):
opffile = os.path.join(dstdir, 'OEBPS', 'content.opf') opffile = os.path.join(dstdir, 'OEBPS', 'content.opf')
# read the first file resolution
profilelabel, deviceres, palette, gamma, panelviewsize = options.profileData profilelabel, deviceres, palette, gamma, panelviewsize = options.profileData
imgres = str(deviceres[0]) + "x" + str(deviceres[1]) imgres = str(deviceres[0]) + "x" + str(deviceres[1])
if options.righttoleft: 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, img.resizeImage(options.upscale, options.stretch, options.black_borders, isSplit, toRight,
options.landscapemode, options.quality) options.landscapemode, options.quality)
img.optimizeImage(options.gamma) img.optimizeImage(options.gamma)
if options.forcepng: if options.forcepng and not options.forcecolor:
img.quantizeImage() img.quantizeImage()
@@ -627,10 +626,8 @@ def getWorkFolder(afile):
def slugify(value): def slugify(value):
""" # Normalizes string, converts to lowercase, removes non-alpha characters,
Normalizes string, converts to lowercase, removes non-alpha characters, # and converts spaces to hyphens.
and converts spaces to hyphens.
"""
import unicodedata import unicodedata
value = unicodedata.normalize('NFKD', unicode(value, 'latin1')).encode('ascii', 'ignore') value = unicodedata.normalize('NFKD', unicode(value, 'latin1')).encode('ascii', 'ignore')
value = re.sub('[^\w\s\.-]', '', value).strip().lower() value = re.sub('[^\w\s\.-]', '', value).strip().lower()
@@ -794,7 +791,7 @@ def checkOptions():
options.panelview = True options.panelview = True
options.landscapemode = False options.landscapemode = False
else: else:
# Virtual Panel View # Virtual Panel View or Panel View disabled
options.panelview = False options.panelview = False
# Older Kindle don't need higher resolution files due lack of Panel View. # 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. # Kindle Fire family have very high resolution. Bigger images are not needed.
@@ -802,10 +799,8 @@ def checkOptions():
or options.profile == 'KF' or options.profile == 'KFHD' or options.profile == 'KFHD8': or options.profile == 'KF' or options.profile == 'KFHD' or options.profile == 'KFHD8':
options.quality = 0 options.quality = 0
# Disabling grayscale conversion for Kindle Fire family. # 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: if options.profile == 'KF' or options.profile == 'KFHD' or options.profile == 'KFHD8' or options.forcecolor:
options.forcecolor = True options.forcecolor = True
options.forcepng = False
else: else:
options.forcecolor = False options.forcecolor = False
# Mixing vertical and horizontal pages require real Panel View. # Mixing vertical and horizontal pages require real Panel View.
+1 -8
View File
@@ -28,14 +28,6 @@ except ImportError:
exit(1) exit(1)
class ImageFlags:
Orient = 1 << 0
Resize = 1 << 1
Frame = 1 << 2
Quantize = 1 << 3
Stretch = 1 << 4
class ProfileData: class ProfileData:
Palette4 = [ Palette4 = [
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -181,6 +173,7 @@ class ComicPage:
size = (self.size[0], self.size[1]) size = (self.size[0], self.size[1])
else: else:
size = (self.panelviewsize[0], self.panelviewsize[1]) size = (self.panelviewsize[0], self.panelviewsize[1])
# Kindle Paperwhite/Touch - Force upscale of splited pages to increase readability
if isSplit and landscapeMode: if isSplit and landscapeMode:
upscale = True upscale = True
if self.image.size[0] <= self.size[0] and self.image.size[1] <= self.size[1]: if self.image.size[0] <= self.size[0] and self.image.size[1] <= self.size[1]:
+2
View File
@@ -0,0 +1,2 @@
[Paths]
Plugins = DumbHackThatFixPY2APP
+27 -15
View File
@@ -2,35 +2,46 @@
cx_Freeze build script for KCC. cx_Freeze build script for KCC.
Usage (Mac OS X): Usage (Mac OS X):
python setup.py bdist_mac python setup.py py2app
Usage (Windows): Usage (Windows):
python setup.py build python setup.py build
""" """
from sys import platform from sys import platform
from cx_Freeze import setup, Executable
NAME = "KindleComicConverter" NAME = "KindleComicConverter"
VERSION = "3.0" VERSION = "3.0"
MAIN = "kcc.py" MAIN = "kcc.py"
includefiles = ['LICENSE.txt']
includes = []
excludes = []
if platform == "darwin": if platform == "darwin":
from setuptools import setup
extra_options = dict( extra_options = dict(
options={"build_exe": {"include_files": includefiles, "excludes": excludes, "compressed": True}, setup_requires=['py2app'],
"bdist_mac": {"iconfile": "icons/comic2ebook.icns"}}, app=[MAIN],
executables=[Executable(MAIN, options=dict(
copyDependentFiles=True, py2app=dict(
appendScriptToExe=True, argv_emulation=True,
appendScriptToLibrary=False, iconfile='icons/comic2ebook.icns',
compress=True)]) 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": elif platform == "win32":
from cx_Freeze import setup, Executable
base = "Win32GUI" base = "Win32GUI"
extra_options = dict( 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, executables=[Executable(MAIN,
base=base, base=base,
targetName="KCC.exe", targetName="KCC.exe",
@@ -40,8 +51,9 @@ elif platform == "win32":
appendScriptToLibrary=False, appendScriptToLibrary=False,
compress=True)]) compress=True)])
else: else:
from cx_Freeze import setup, Executable
extra_options = dict( 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, executables=[Executable(MAIN,
icon="icons/comic2ebook.png", icon="icons/comic2ebook.png",
copyDependentFiles=True, copyDependentFiles=True,