Skip to content

lower part of image disappearing when cropping to size #182

@ElineVG

Description

@ElineVG

Dear @vgalin,

I have been a very big fan of your html2image package!
In previous versions I did not experience this issue but now I do (I think because of the changes in headless browser?):

When I crop the screenshot to a certain size, the lower part of the screenshot disappears.

Now I have a workaround where I save the full screenshot and then crop to size using PIL (getbbox), but it would be cleaner if this issue would be solved within html2image.

Any solution would be very much appreciated! I am sorry in case I overlooked other issues on this problem.

Reproducible example:

img.svg:

<?xml version="1.0" encoding="utf-8" ?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink" baseProfile="full" height="420" version="1.1" width="420">
    <rect fill="blue" height="420" width="420" x="0" y="0"/>
</svg>

test.py:

from html2image import Html2Image

hti = Html2Image()

_ = hti.screenshot(other_file="img.svg", save_as='img.png')
_ = hti.screenshot(other_file="img.svg", save_as='img_sized.png', size=(420, 420))

Non-cropped gives square of 420x420 with blank space around:

Image

Blue part is not square when cropping to 420x420:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions