View Single Post
Old 06-16-2019, 06:59 AM   #639
worstje
Member
worstje began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Jun 2019
Device: none
I ran into a bug while using this. The image can end up not being properly centered if fitting to the available space and using an image border.

To fix it, include:

Code:
            lwidth, lheight = logo.size  # add_border() changes dimensions
after line 231. The relevant snippet of code should now look as follows:

Code:
    if not is_background_image and display_image and available[1] > 40:
        logo = Image()
        logo.open(image_path)
        lwidth, lheight = logo.size
        available = (available[0] - image_border_width * 2,
                     available[1] - image_border_width * 2)
        scaled, lwidth, lheight = fit_image(lwidth, lheight, *available)
        if not scaled and options.get(cfg.KEY_RESIZE_IMAGE_TO_FIT, False):
            scaled, lwidth, lheight = scaleup_image(
                lwidth, lheight, *available)
        if scaled:
            logo.size = (lwidth, lheight)
        if image_border_width > 0:
            logo = add_border(logo, image_border_width, border_color, bgcolor)
            lwidth, lheight = logo.size  # add_border() changes dimensions

        left = int(max(0, (width - lwidth) / 2.))
        top = top + image_mgn + ((available[1] - lheight) / 2.)
        canvas.compose(logo, int(left), int(top))
Note: I am not sure if this is the ideal fix. (I think that it might just subtly breaks the logic of the available space and exceeds it? The logic confuses me!) I just know it fixes it well enough for me in practice given that there's always plenty of padding and margins all around on my covers.

A sincere thank you goes out to whoever maintains this plugin nowadays.

Last edited by worstje; 06-16-2019 at 07:03 AM. Reason: gotta be more specific
worstje is offline   Reply With Quote