diff --git a/src/calibre/utils/magick/draw.py b/src/calibre/utils/magick/draw.py index 17bf1c273a..82a0237b8d 100644 --- a/src/calibre/utils/magick/draw.py +++ b/src/calibre/utils/magick/draw.py @@ -165,12 +165,17 @@ def create_cover_page(top_lines, logo_path, width=590, height=750, top = height - lheight - 10 canvas.compose(vanity, left, top) - logo = Image() - logo.open(logo_path) - lwidth, lheight = logo.size - left = int(max(0, (width - lwidth)/2.)) - top = max(int((height - lheight)/2.), bottom+20) - canvas.compose(logo, left, top) + available = (width, int(top - bottom)-20) + if available[1] > 40: + logo = Image() + logo.open(logo_path) + lwidth, lheight = logo.size + 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)