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)

This commit is contained in:
Kovid Goyal 2011-01-30 18:06:54 -07:00
parent 3ade51c731
commit 2233dab924
3 changed files with 41 additions and 16 deletions

View File

@ -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])) prints('\t'+'\n\t'.join([os.path.basename(p) for p in pages]))
return pages return pages
class PageProcessor(list): class PageProcessor(list): # {{{
''' '''
Contains the actual image rendering logic. See :method:`render` and Contains the actual image rendering logic. See :method:`render` and
:method:`process_pages`. :method:`process_pages`.
@ -111,6 +111,13 @@ class PageProcessor(list):
SCRWIDTH, SCRHEIGHT = self.opts.output_profile.comic_screen_size 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: if self.opts.keep_aspect_ratio:
# Preserve the aspect ratio by adding border # Preserve the aspect ratio by adding border
aspect = float(sizex) / float(sizey) aspect = float(sizex) / float(sizey)
@ -170,6 +177,7 @@ class PageProcessor(list):
dest = dest[:-1] dest = dest[:-1]
os.rename(dest+'8', dest) os.rename(dest+'8', dest)
self.append(dest) self.append(dest)
# }}}
def render_pages(tasks, dest, opts, notification=lambda x, y: x): 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, OptionRecommendation(name='no_process', recommended_value=False,
help=_("Apply no processing to the image")), help=_("Apply no processing to the image")),
OptionRecommendation(name='dont_grayscale', recommended_value=False, 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([ recommendations = set([

View File

@ -22,7 +22,7 @@ class PluginWidget(Widget, Ui_Form):
['colors', 'dont_normalize', 'keep_aspect_ratio', 'right2left', ['colors', 'dont_normalize', 'keep_aspect_ratio', 'right2left',
'despeckle', 'no_sort', 'no_process', 'landscape', 'despeckle', 'no_sort', 'no_process', 'landscape',
'dont_sharpen', 'disable_trim', 'wide', 'output_format', 'dont_sharpen', 'disable_trim', 'wide', 'output_format',
'dont_grayscale'] 'dont_grayscale', 'comic_image_size']
) )
self.db, self.book_id = db, book_id self.db, self.book_id = db, book_id
for x in get_option('output_format').option.choices: for x in get_option('output_format').option.choices:

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>599</width> <width>599</width>
<height>345</height> <height>398</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -37,70 +37,70 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="4" column="0">
<widget class="QCheckBox" name="opt_dont_normalize"> <widget class="QCheckBox" name="opt_dont_normalize">
<property name="text"> <property name="text">
<string>Disable &amp;normalize</string> <string>Disable &amp;normalize</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="5" column="0">
<widget class="QCheckBox" name="opt_keep_aspect_ratio"> <widget class="QCheckBox" name="opt_keep_aspect_ratio">
<property name="text"> <property name="text">
<string>Keep &amp;aspect ratio</string> <string>Keep &amp;aspect ratio</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="6" column="0">
<widget class="QCheckBox" name="opt_dont_sharpen"> <widget class="QCheckBox" name="opt_dont_sharpen">
<property name="text"> <property name="text">
<string>Disable &amp;Sharpening</string> <string>Disable &amp;Sharpening</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="7" column="0">
<widget class="QCheckBox" name="opt_disable_trim"> <widget class="QCheckBox" name="opt_disable_trim">
<property name="text"> <property name="text">
<string>Disable &amp;Trimming</string> <string>Disable &amp;Trimming</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="8" column="0">
<widget class="QCheckBox" name="opt_wide"> <widget class="QCheckBox" name="opt_wide">
<property name="text"> <property name="text">
<string>&amp;Wide</string> <string>&amp;Wide</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0"> <item row="9" column="0">
<widget class="QCheckBox" name="opt_landscape"> <widget class="QCheckBox" name="opt_landscape">
<property name="text"> <property name="text">
<string>&amp;Landscape</string> <string>&amp;Landscape</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0"> <item row="10" column="0">
<widget class="QCheckBox" name="opt_right2left"> <widget class="QCheckBox" name="opt_right2left">
<property name="text"> <property name="text">
<string>&amp;Right to left</string> <string>&amp;Right to left</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="0"> <item row="11" column="0">
<widget class="QCheckBox" name="opt_no_sort"> <widget class="QCheckBox" name="opt_no_sort">
<property name="text"> <property name="text">
<string>Don't so&amp;rt</string> <string>Don't so&amp;rt</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="0"> <item row="12" column="0">
<widget class="QCheckBox" name="opt_despeckle"> <widget class="QCheckBox" name="opt_despeckle">
<property name="text"> <property name="text">
<string>De&amp;speckle</string> <string>De&amp;speckle</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="13" column="0"> <item row="14" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -120,7 +120,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="0"> <item row="13" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>&amp;Output format:</string> <string>&amp;Output format:</string>
@ -130,7 +130,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="1"> <item row="13" column="1">
<widget class="QComboBox" name="opt_output_format"/> <widget class="QComboBox" name="opt_output_format"/>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
@ -140,6 +140,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Override image &amp;size:</string>
</property>
<property name="buddy">
<cstring>opt_comic_image_size</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="opt_comic_image_size"/>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>