From 2233dab9248fac21c6776d5b9b9fbd7e0613edd7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 30 Jan 2011 18:06:54 -0700 Subject: [PATCH] Comic input: Add an option to override the image size in the geenrated comic. Useful if you have a device whose screen size is not coverred by one of the available output profiles. Fixes #7837 (need new profile added) --- src/calibre/ebooks/comic/input.py | 16 ++++++++-- src/calibre/gui2/convert/comic_input.py | 2 +- src/calibre/gui2/convert/comic_input.ui | 39 ++++++++++++++++--------- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/calibre/ebooks/comic/input.py b/src/calibre/ebooks/comic/input.py index 04d097ac67..c9b11e31f2 100755 --- a/src/calibre/ebooks/comic/input.py +++ b/src/calibre/ebooks/comic/input.py @@ -53,7 +53,7 @@ def find_pages(dir, sort_on_mtime=False, verbose=False): prints('\t'+'\n\t'.join([os.path.basename(p) for p in pages])) return pages -class PageProcessor(list): +class PageProcessor(list): # {{{ ''' Contains the actual image rendering logic. See :method:`render` and :method:`process_pages`. @@ -111,6 +111,13 @@ class PageProcessor(list): SCRWIDTH, SCRHEIGHT = self.opts.output_profile.comic_screen_size + try: + if self.opts.comic_image_size: + SCRWIDTH, SCRHEIGHT = map(int, [x.strip() for x in + self.opts.comic_image_size.split('x')]) + except: + pass # Ignore + if self.opts.keep_aspect_ratio: # Preserve the aspect ratio by adding border aspect = float(sizex) / float(sizey) @@ -170,6 +177,7 @@ class PageProcessor(list): dest = dest[:-1] os.rename(dest+'8', dest) self.append(dest) +# }}} def render_pages(tasks, dest, opts, notification=lambda x, y: x): ''' @@ -291,7 +299,11 @@ class ComicInput(InputFormatPlugin): 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)')) + help=_('Do not convert the image to grayscale (black and white)')), + OptionRecommendation(name='comic_image_size', recommended_value=None, + help=_('Specify the image size as widthxheight pixels. Normally,' + ' an image size is automatically calculated from the output ' + 'profile, this option overrides it.')), ]) recommendations = set([ diff --git a/src/calibre/gui2/convert/comic_input.py b/src/calibre/gui2/convert/comic_input.py index fe86f133d1..f7f8023c0e 100644 --- a/src/calibre/gui2/convert/comic_input.py +++ b/src/calibre/gui2/convert/comic_input.py @@ -22,7 +22,7 @@ class PluginWidget(Widget, Ui_Form): ['colors', 'dont_normalize', 'keep_aspect_ratio', 'right2left', 'despeckle', 'no_sort', 'no_process', 'landscape', 'dont_sharpen', 'disable_trim', 'wide', 'output_format', - 'dont_grayscale'] + 'dont_grayscale', 'comic_image_size'] ) 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 c3b363d7e9..52c0ad2bb5 100644 --- a/src/calibre/gui2/convert/comic_input.ui +++ b/src/calibre/gui2/convert/comic_input.ui @@ -7,7 +7,7 @@ 0 0 599 - 345 + 398 @@ -37,70 +37,70 @@ - + 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,7 +130,7 @@ - + @@ -140,6 +140,19 @@ + + + + Override image &size: + + + opt_comic_image_size + + + + + +