From 9b8edf21a217b77fa617127e55170bfa99e7544b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 31 Mar 2010 07:30:14 +0530 Subject: [PATCH] Comic Input: Add option to disable conversion to grayscale (black and white) --- src/calibre/ebooks/comic/input.py | 5 +- src/calibre/gui2/convert/comic_input.py | 3 +- src/calibre/gui2/convert/comic_input.ui | 91 ++++++++++++++++--------- src/calibre/gui2/wizard/__init__.py | 5 ++ 4 files changed, 68 insertions(+), 36 deletions(-) diff --git a/src/calibre/ebooks/comic/input.py b/src/calibre/ebooks/comic/input.py index 6fba918888..925416627f 100755 --- a/src/calibre/ebooks/comic/input.py +++ b/src/calibre/ebooks/comic/input.py @@ -171,7 +171,8 @@ class PageProcessor(list): if not self.opts.dont_sharpen: p.MagickSharpenImage(wand, 0.0, 1.0) - p.MagickSetImageType(wand, p.GrayscaleType) + if not self.opts.dont_grayscale: + p.MagickSetImageType(wand, p.GrayscaleType) if self.opts.despeckle: p.MagickDespeckleImage(wand) @@ -310,6 +311,8 @@ class ComicInput(InputFormatPlugin): 'you optimal size and look on your device.')), OptionRecommendation(name='no_process', recommended_value=False, help=_("Apply no processing to the image")), + OptionRecommendation(name='dont_grayscale', recommended_value=False, + help=_('Do not convert the image to grayscale (black and white)')) ]) recommendations = set([ diff --git a/src/calibre/gui2/convert/comic_input.py b/src/calibre/gui2/convert/comic_input.py index bfa5eb5c63..25c39fe138 100644 --- a/src/calibre/gui2/convert/comic_input.py +++ b/src/calibre/gui2/convert/comic_input.py @@ -19,7 +19,8 @@ class PluginWidget(Widget, Ui_Form): Widget.__init__(self, parent, 'comic_input', ['colors', 'dont_normalize', 'keep_aspect_ratio', 'right2left', 'despeckle', 'no_sort', 'no_process', 'landscape', - 'dont_sharpen', 'disable_trim', 'wide', 'output_format'] + 'dont_sharpen', 'disable_trim', 'wide', 'output_format', + 'dont_grayscale'] ) self.db, self.book_id = db, book_id for x in get_option('output_format').option.choices: diff --git a/src/calibre/gui2/convert/comic_input.ui b/src/calibre/gui2/convert/comic_input.ui index f4f2d35e91..c3b363d7e9 100644 --- a/src/calibre/gui2/convert/comic_input.ui +++ b/src/calibre/gui2/convert/comic_input.ui @@ -7,14 +7,14 @@ 0 0 599 - 343 + 345 Form - + &Number of Colors: @@ -24,83 +24,83 @@ - + 8 - 3200000 + 32000000 8 - + Disable &normalize - + Keep &aspect ratio - + Disable &Sharpening - + Disable &Trimming - + &Wide - + &Landscape - + &Right to left - + Don't so&rt - + De&speckle - + Qt::Vertical @@ -120,7 +120,7 @@ - + &Output format: @@ -130,9 +130,16 @@ - + + + + + Disable conversion of images to &black and white + + + @@ -148,8 +155,8 @@ 11 - 210 - 44 + 216 + 76 @@ -164,8 +171,8 @@ 17 - 371 - 39 + 592 + 76 @@ -180,8 +187,8 @@ 15 - 20 - 67 + 26 + 101 @@ -196,8 +203,8 @@ 11 - 38 - 98 + 44 + 126 @@ -212,8 +219,8 @@ 12 - 110 - 124 + 116 + 151 @@ -224,12 +231,12 @@ setDisabled(bool) - 153 - 5 + 159 + 11 - 67 - 155 + 73 + 176 @@ -244,8 +251,8 @@ 13 - 84 - 180 + 90 + 201 @@ -292,8 +299,8 @@ 11 - 105 - 256 + 111 + 276 @@ -329,5 +336,21 @@ + + opt_no_process + toggled(bool) + opt_dont_grayscale + setDisabled(bool) + + + 229 + 22 + + + 231 + 36 + + + diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py index d47005a9ee..d24d3bb6c1 100644 --- a/src/calibre/gui2/wizard/__init__.py +++ b/src/calibre/gui2/wizard/__init__.py @@ -299,6 +299,11 @@ class StanzaPage(QWizardPage, StanzaUI): return FinishPage.ID def commit(self): + from calibre.ebooks.conversion.config import load_defaults, save_defaults + recs = load_defaults('comic_input') + recs['dont_grayscale'] = True + save_defaults('comic_input', recs) + p = self.set_port() if p is not None: from calibre.library import server_config