mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Comic Input: Change default colors to 256 and add option to generate comic pages in PNG or JPEG formats. Fixes #3529 (Comics display badly on Adobe Digital Editions and some prs-505 models due to colour depth)
This commit is contained in:
parent
ffc7042af4
commit
d31192ece3
@ -173,7 +173,7 @@ class PageProcessor(list):
|
|||||||
p.MagickDespeckleImage(wand)
|
p.MagickDespeckleImage(wand)
|
||||||
|
|
||||||
p.MagickQuantizeImage(wand, self.opts.colors, p.RGBColorspace, 0, 1, 0)
|
p.MagickQuantizeImage(wand, self.opts.colors, p.RGBColorspace, 0, 1, 0)
|
||||||
dest = '%d_%d.png'%(self.num, i)
|
dest = '%d_%d.%s'%(self.num, i, self.opts.output_format)
|
||||||
dest = os.path.join(self.dest, dest)
|
dest = os.path.join(self.dest, dest)
|
||||||
p.MagickWriteImage(wand, dest+'8')
|
p.MagickWriteImage(wand, dest+'8')
|
||||||
os.rename(dest+'8', dest)
|
os.rename(dest+'8', dest)
|
||||||
@ -270,8 +270,10 @@ class ComicInput(InputFormatPlugin):
|
|||||||
is_image_collection = True
|
is_image_collection = True
|
||||||
|
|
||||||
options = set([
|
options = set([
|
||||||
OptionRecommendation(name='colors', recommended_value=64,
|
OptionRecommendation(name='colors', recommended_value=256,
|
||||||
help=_('Number of colors for grayscale image conversion. Default: %default')),
|
help=_('Number of colors for grayscale image conversion. Default: '
|
||||||
|
'%default. Values of less than 256 may result in blurred text '
|
||||||
|
'on your device if you are creating your comics in EPUB format.')),
|
||||||
OptionRecommendation(name='dont_normalize', recommended_value=False,
|
OptionRecommendation(name='dont_normalize', recommended_value=False,
|
||||||
help=_('Disable normalize (improve contrast) color range '
|
help=_('Disable normalize (improve contrast) color range '
|
||||||
'for pictures. Default: False')),
|
'for pictures. Default: False')),
|
||||||
@ -298,6 +300,10 @@ class ComicInput(InputFormatPlugin):
|
|||||||
help=_("Don't sort the files found in the comic "
|
help=_("Don't sort the files found in the comic "
|
||||||
"alphabetically by name. Instead use the order they were "
|
"alphabetically by name. Instead use the order they were "
|
||||||
"added to the comic.")),
|
"added to the comic.")),
|
||||||
|
OptionRecommendation(name='output_format', choices=['png', 'jpg'],
|
||||||
|
recommended_value='png', help=_('The format that images in the created ebook '
|
||||||
|
'are converted to. You can experiment to see which format gives '
|
||||||
|
'you optimal size and look on your device.')),
|
||||||
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")),
|
||||||
])
|
])
|
||||||
@ -365,7 +371,8 @@ class ComicInput(InputFormatPlugin):
|
|||||||
'(run with --verbose to see why):')
|
'(run with --verbose to see why):')
|
||||||
for f in failures:
|
for f in failures:
|
||||||
self.log.warning('\t', f)
|
self.log.warning('\t', f)
|
||||||
thumbnail = os.path.join(tdir2, 'thumbnail.png')
|
thumbnail = os.path.join(tdir2,
|
||||||
|
'thumbnail.'+self.opts.output_format.lower())
|
||||||
if not os.access(thumbnail, os.R_OK):
|
if not os.access(thumbnail, os.R_OK):
|
||||||
thumbnail = None
|
thumbnail = None
|
||||||
return new_pages
|
return new_pages
|
||||||
|
@ -19,9 +19,11 @@ class PluginWidget(Widget, Ui_Form):
|
|||||||
Widget.__init__(self, parent, 'comic_input',
|
Widget.__init__(self, parent, 'comic_input',
|
||||||
['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']
|
'dont_sharpen', 'disable_trim', 'wide', 'output_format']
|
||||||
)
|
)
|
||||||
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:
|
||||||
|
self.opt_output_format.addItem(x)
|
||||||
self.initialize_options(get_option, get_help, db, book_id)
|
self.initialize_options(get_option, get_help, db, book_id)
|
||||||
self.opt_no_process.toggle()
|
self.opt_no_process.toggle()
|
||||||
self.opt_no_process.toggle()
|
self.opt_no_process.toggle()
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>599</width>
|
<width>599</width>
|
||||||
<height>305</height>
|
<height>343</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -100,7 +100,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="0">
|
<item row="12" column="0">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -120,6 +120,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="11" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Output format:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>opt_output_format</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="1">
|
||||||
|
<widget class="QComboBox" name="opt_output_format"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
@ -263,8 +276,8 @@
|
|||||||
<y>15</y>
|
<y>15</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>52</x>
|
<x>56</x>
|
||||||
<y>225</y>
|
<y>248</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
@ -300,5 +313,21 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>opt_no_process</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>opt_output_format</receiver>
|
||||||
|
<slot>setDisabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>237</x>
|
||||||
|
<y>12</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>370</x>
|
||||||
|
<y>308</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user