mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement #985 (comic2lrf, added a wide-aspect scaling option)
This commit is contained in:
commit
cf55451ecc
@ -37,7 +37,7 @@ except:
|
|||||||
|
|
||||||
PROFILES = {
|
PROFILES = {
|
||||||
# Name : (width, height) in pixels
|
# Name : (width, height) in pixels
|
||||||
'prs500':(584, 754),
|
'prs500':(584, 754),
|
||||||
}
|
}
|
||||||
|
|
||||||
def extract_comic(path_to_comic_file):
|
def extract_comic(path_to_comic_file):
|
||||||
@ -143,7 +143,7 @@ class PageProcessor(list):
|
|||||||
|
|
||||||
SCRWIDTH, SCRHEIGHT = PROFILES[self.opts.profile]
|
SCRWIDTH, SCRHEIGHT = PROFILES[self.opts.profile]
|
||||||
print 77777, threading.currentThread()
|
print 77777, threading.currentThread()
|
||||||
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)
|
||||||
if aspect <= (float(SCRWIDTH) / float(SCRHEIGHT)):
|
if aspect <= (float(SCRWIDTH) / float(SCRHEIGHT)):
|
||||||
@ -159,6 +159,27 @@ class PageProcessor(list):
|
|||||||
MagickResizeImage(wand, newsizex, newsizey, CatromFilter, 1.0)
|
MagickResizeImage(wand, newsizex, newsizey, CatromFilter, 1.0)
|
||||||
MagickSetImageBorderColor(wand, pw)
|
MagickSetImageBorderColor(wand, pw)
|
||||||
MagickBorderImage(wand, pw, deltax, deltay)
|
MagickBorderImage(wand, pw, deltax, deltay)
|
||||||
|
elif self.opts.wide:
|
||||||
|
# Keep aspect and Use device height as scaled image width so landscape mode is clean
|
||||||
|
aspect = float(sizex) / float(sizey)
|
||||||
|
screen_aspect = float(SCRWIDTH) / float(SCRHEIGHT)
|
||||||
|
# Get dimensions of the landscape mode screen
|
||||||
|
# Add 25px back to height for the battery bar.
|
||||||
|
wscreenx = SCRHEIGHT + 25
|
||||||
|
wscreeny = int(wscreenx / screen_aspect)
|
||||||
|
if aspect <= screen_aspect:
|
||||||
|
newsizey = wscreeny
|
||||||
|
newsizex = int(newsizey * aspect)
|
||||||
|
deltax = (wscreenx - newsizex) / 2
|
||||||
|
deltay = 0
|
||||||
|
else:
|
||||||
|
newsizex = wscreenx
|
||||||
|
newsizey = int(newsizex / aspect)
|
||||||
|
deltax = 0
|
||||||
|
deltay = (wscreeny - newsizey) / 2
|
||||||
|
MagickResizeImage(wand, newsizex, newsizey, CatromFilter, 1.0)
|
||||||
|
MagickSetImageBorderColor(wand, pw)
|
||||||
|
MagickBorderImage(wand, pw, deltax, deltay)
|
||||||
else:
|
else:
|
||||||
MagickResizeImage(wand, SCRWIDTH, SCRHEIGHT, CatromFilter, 1.0)
|
MagickResizeImage(wand, SCRWIDTH, SCRHEIGHT, CatromFilter, 1.0)
|
||||||
|
|
||||||
@ -234,34 +255,36 @@ def config(defaults=None):
|
|||||||
c = Config('comic', desc)
|
c = Config('comic', desc)
|
||||||
else:
|
else:
|
||||||
c = StringConfig(defaults, desc)
|
c = StringConfig(defaults, desc)
|
||||||
c.add_opt('title', ['-t', '--title'],
|
c.add_opt('title', ['-t', '--title'],
|
||||||
help=_('Title for generated ebook. Default is to use the filename.'))
|
help=_('Title for generated ebook. Default is to use the filename.'))
|
||||||
c.add_opt('author', ['-a', '--author'],
|
c.add_opt('author', ['-a', '--author'],
|
||||||
help=_('Set the author in the metadata of the generated ebook. Default is %default'),
|
help=_('Set the author in the metadata of the generated ebook. Default is %default'),
|
||||||
default=_('Unknown'))
|
default=_('Unknown'))
|
||||||
c.add_opt('output', ['-o', '--output'],
|
c.add_opt('output', ['-o', '--output'],
|
||||||
help=_('Path to output LRF file. By default a file is created in the current directory.'))
|
help=_('Path to output LRF file. By default a file is created in the current directory.'))
|
||||||
c.add_opt('colors', ['-c', '--colors'], type='int', default=64,
|
c.add_opt('colors', ['-c', '--colors'], type='int', default=64,
|
||||||
help=_('Number of colors for grayscale image conversion. Default: %default'))
|
help=_('Number of colors for grayscale image conversion. Default: %default'))
|
||||||
c.add_opt('dont_normalize', ['-n', '--disable-normalize'], default=False,
|
c.add_opt('dont_normalize', ['-n', '--disable-normalize'], default=False,
|
||||||
help=_('Disable normalize (improve contrast) color range for pictures. Default: False'))
|
help=_('Disable normalize (improve contrast) color range for pictures. Default: False'))
|
||||||
c.add_opt('keep_aspect_ratio', ['-r', '--keep-aspect-ratio'], default=False,
|
c.add_opt('keep_aspect_ratio', ['-r', '--keep-aspect-ratio'], default=False,
|
||||||
help=_('Maintain picture aspect ratio. Default is to fill the screen.'))
|
help=_('Maintain picture aspect ratio. Default is to fill the screen.'))
|
||||||
c.add_opt('dont_sharpen', ['-s', '--disable-sharpen'], default=False,
|
c.add_opt('dont_sharpen', ['-s', '--disable-sharpen'], default=False,
|
||||||
help=_('Disable sharpening.'))
|
help=_('Disable sharpening.'))
|
||||||
c.add_opt('landscape', ['-l', '--landscape'], default=False,
|
c.add_opt('landscape', ['-l', '--landscape'], default=False,
|
||||||
help=_("Don't split landscape images into two portrait images"))
|
help=_("Don't split landscape images into two portrait images"))
|
||||||
|
c.add_opt('wide', ['-w', '--wide-aspect'], default=False,
|
||||||
|
help=_("Keep aspect ratio and scale image using screen height as image width for viewing in landscape mode."))
|
||||||
c.add_opt('right2left', ['--right2left'], default=False, action='store_true',
|
c.add_opt('right2left', ['--right2left'], default=False, action='store_true',
|
||||||
help=_('Used for right-to-left publications like manga. Causes landscape pages to be split into portrait pages from right to left.'))
|
help=_('Used for right-to-left publications like manga. Causes landscape pages to be split into portrait pages from right to left.'))
|
||||||
c.add_opt('despeckle', ['-d', '--despeckle'], default=False,
|
c.add_opt('despeckle', ['-d', '--despeckle'], default=False,
|
||||||
help=_('Enable Despeckle. Reduces speckle noise. May greatly increase processing time.'))
|
help=_('Enable Despeckle. Reduces speckle noise. May greatly increase processing time.'))
|
||||||
c.add_opt('no_sort', ['--no-sort'], default=False,
|
c.add_opt('no_sort', ['--no-sort'], default=False,
|
||||||
help=_("Don't sort the files found in the comic alphabetically by name. Instead use the order they were added to the comic."))
|
help=_("Don't sort the files found in the comic alphabetically by name. Instead use the order they were added to the comic."))
|
||||||
c.add_opt('profile', ['-p', '--profile'], default='prs500', choices=PROFILES.keys(),
|
c.add_opt('profile', ['-p', '--profile'], default='prs500', choices=PROFILES.keys(),
|
||||||
help=_('Choose a profile for the device you are generating this LRF for. The default is the SONY PRS-500 with a screen size of 584x754 pixels. Choices are %s')%PROFILES.keys())
|
help=_('Choose a profile for the device you are generating this LRF for. The default is the SONY PRS-500 with a screen size of 584x754 pixels. Choices are %s')%PROFILES.keys())
|
||||||
c.add_opt('verbose', ['--verbose'], default=0, action='count',
|
c.add_opt('verbose', ['--verbose'], default=0, action='count',
|
||||||
help=_('Be verbose, useful for debugging. Can be specified multiple times for greater verbosity.'))
|
help=_('Be verbose, useful for debugging. Can be specified multiple times for greater verbosity.'))
|
||||||
c.add_opt('no_progress_bar', ['--no-progress-bar'], default=False,
|
c.add_opt('no_progress_bar', ['--no-progress-bar'], default=False,
|
||||||
help=_("Don't show progress bar."))
|
help=_("Don't show progress bar."))
|
||||||
return c
|
return c
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ class ComicConf(QDialog, Ui_Dialog):
|
|||||||
self.opt_landscape.setChecked(opts.landscape)
|
self.opt_landscape.setChecked(opts.landscape)
|
||||||
self.opt_no_sort.setChecked(opts.no_sort)
|
self.opt_no_sort.setChecked(opts.no_sort)
|
||||||
self.opt_despeckle.setChecked(opts.despeckle)
|
self.opt_despeckle.setChecked(opts.despeckle)
|
||||||
|
self.opt_wide.setChecked(opts.wide)
|
||||||
self.opt_right2left.setChecked(opts.right2left)
|
self.opt_right2left.setChecked(opts.right2left)
|
||||||
|
|
||||||
for opt in self.config.option_set.preferences:
|
for opt in self.config.option_set.preferences:
|
||||||
@ -80,4 +81,4 @@ class ComicConf(QDialog, Ui_Dialog):
|
|||||||
else:
|
else:
|
||||||
raise Exception('Bad coding')
|
raise Exception('Bad coding')
|
||||||
self.config.set(opt.name, val)
|
self.config.set(opt.name, val)
|
||||||
return QDialog.accept(self)
|
return QDialog.accept(self)
|
||||||
|
@ -100,21 +100,21 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0" >
|
<item row="8" column="0" >
|
||||||
<widget class="QCheckBox" name="opt_landscape" >
|
<widget class="QCheckBox" name="opt_landscape" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>&Landscape</string>
|
<string>&Landscape</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0" >
|
<item row="10" 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&rt</string>
|
<string>Don't so&rt</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="1" >
|
<item row="12" column="1" >
|
||||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -124,20 +124,27 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0" >
|
<item row="9" column="0" >
|
||||||
<widget class="QCheckBox" name="opt_right2left" >
|
<widget class="QCheckBox" name="opt_right2left" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>&Right to left</string>
|
<string>&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_despeckle" >
|
<widget class="QCheckBox" name="opt_despeckle" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>De&speckle</string>
|
<string>De&speckle</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="7" column="0" >
|
||||||
|
<widget class="QCheckBox" name="opt_wide" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>&Wide</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user