parent
7c2cb1b347
commit
4d69a58411
@ -400,7 +400,16 @@ def parse_opts(cmdline_args=None):
|
|||||||
dest="tabs_only",
|
dest="tabs_only",
|
||||||
help="Draw only the divider tabs and no divider outlines. "
|
help="Draw only the divider tabs and no divider outlines. "
|
||||||
"Used to print the divider tabs on labels.")
|
"Used to print the divider tabs on labels.")
|
||||||
|
group_printing.add_argument(
|
||||||
|
"--preview",
|
||||||
|
action='store_true',
|
||||||
|
help="Only generate a preview png image of the first page"
|
||||||
|
)
|
||||||
|
group_printing.add_argument(
|
||||||
|
"--preview_resolution",
|
||||||
|
type=int,
|
||||||
|
default=150,
|
||||||
|
help="resolution in DPI to render preview at, for --preview option")
|
||||||
# Special processing
|
# Special processing
|
||||||
group_special = parser.add_argument_group(
|
group_special = parser.add_argument_group(
|
||||||
'Miscellaneous',
|
'Miscellaneous',
|
||||||
@ -463,10 +472,13 @@ def generate_sample(options):
|
|||||||
from wand.image import Image
|
from wand.image import Image
|
||||||
buf = cStringIO.StringIO()
|
buf = cStringIO.StringIO()
|
||||||
options.num_pages = 1
|
options.num_pages = 1
|
||||||
generate(options, '.', buf)
|
options.outfile = buf
|
||||||
with Image(blob=buf.getvalue()) as sample:
|
generate(options)
|
||||||
|
sample_out = cStringIO.StringIO()
|
||||||
|
with Image(blob=buf.getvalue(), resolution=options.preview_resolution) as sample:
|
||||||
sample.format = 'png'
|
sample.format = 'png'
|
||||||
sample.save(filename='sample.png')
|
sample.save(sample_out)
|
||||||
|
return sample_out
|
||||||
|
|
||||||
|
|
||||||
def parse_papersize(spec):
|
def parse_papersize(spec):
|
||||||
@ -1125,4 +1137,8 @@ def generate(options):
|
|||||||
def main():
|
def main():
|
||||||
options = parse_opts()
|
options = parse_opts()
|
||||||
options = clean_opts(options)
|
options = clean_opts(options)
|
||||||
return generate(options)
|
if options.preview:
|
||||||
|
fname = '{}.{}'.format(os.path.splitext(options.outfile)[0], 'png')
|
||||||
|
open(fname, 'wb').write(generate_sample(options).getvalue())
|
||||||
|
else:
|
||||||
|
generate(options)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user