mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Cover generation: Scale logo to fit in available space
This commit is contained in:
parent
dd8e6229fc
commit
965413b392
@ -165,12 +165,17 @@ def create_cover_page(top_lines, logo_path, width=590, height=750,
|
|||||||
top = height - lheight - 10
|
top = height - lheight - 10
|
||||||
canvas.compose(vanity, left, top)
|
canvas.compose(vanity, left, top)
|
||||||
|
|
||||||
logo = Image()
|
available = (width, int(top - bottom)-20)
|
||||||
logo.open(logo_path)
|
if available[1] > 40:
|
||||||
lwidth, lheight = logo.size
|
logo = Image()
|
||||||
left = int(max(0, (width - lwidth)/2.))
|
logo.open(logo_path)
|
||||||
top = max(int((height - lheight)/2.), bottom+20)
|
lwidth, lheight = logo.size
|
||||||
canvas.compose(logo, left, top)
|
scaled, lwidth, lheight = fit_image(lwidth, lheight, *available)
|
||||||
|
if scaled:
|
||||||
|
logo.size = (lwidth, lheight)
|
||||||
|
left = int(max(0, (width - lwidth)/2.))
|
||||||
|
top = bottom+10
|
||||||
|
canvas.compose(logo, left, top)
|
||||||
|
|
||||||
return canvas.export(output_format)
|
return canvas.export(output_format)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user