Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CairoError: CAIRO_STATUS_INVALID_MATRIX #217

Closed
lilydjwg opened this issue Sep 10, 2014 · 3 comments
Closed

CairoError: CAIRO_STATUS_INVALID_MATRIX #217

lilydjwg opened this issue Sep 10, 2014 · 3 comments

Comments

@lilydjwg
Copy link

WeasyPrint raises CairoError with the following HTML document (the background image must exist):

<style type="text/css">
  div {
    background-image: url("t.png");
    display: inline-block;
    background-size: cover;
  }
</style>
<div></div>

The error is:

Traceback (most recent call last):
  File ".../venv/bin/weasyprint", line 9, in <module>
    load_entry_point('WeasyPrint==0.22', 'console_scripts', 'weasyprint')()
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/__main__.py", line 156, in main
    getattr(html, 'write_' + format_)(output, **kwargs)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/__init__.py", line 200, in write_png
    .write_png(target, resolution))
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/document.py", line 543, in write_png
    surface, max_width, sum_heights = self.write_image_surface(resolution)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/document.py", line 518, in write_image_surface
    page.paint(context, pos_x, pos_y, scale=dppx, clip=True)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/document.py", line 241, in paint
    draw_page(self._page_box, cairo_context, self._enable_hinting)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/draw.py", line 102, in draw_page
    draw_stacking_context(context, stacking_context, enable_hinting)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/draw.py", line 216, in draw_stacking_context
    draw_stacking_context(context, child_context, enable_hinting)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/draw.py", line 212, in draw_stacking_context
    enable_hinting)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/draw.py", line 843, in draw_inline_level
    draw_inline_level(context, page, child, enable_hinting)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/draw.py", line 834, in draw_inline_level
    draw_stacking_context(context, stacking_context, enable_hinting)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/draw.py", line 168, in draw_stacking_context
    context, stacking_context.page, box, enable_hinting)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/draw.py", line 106, in draw_box_background_and_border
    draw_background(context, box.background, enable_hinting)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/draw.py", line 302, in draw_background
    draw_background_image(context, layer, bg.image_rendering)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/draw.py", line 349, in draw_background_image
    layer.image.draw(sub_context, image_width, image_height, image_rendering)
  File ".../venv/local/lib/python2.7/site-packages/weasyprint/images.py", line 81, in draw
    concrete_height / self._intrinsic_height)
  File ".../venv/local/lib/python2.7/site-packages/cairocffi/context.py", line 707, in scale
    self._check_status()
  File ".../venv/local/lib/python2.7/site-packages/cairocffi/context.py", line 108, in _check_status
    _check_status(cairo.cairo_status(self._pointer))
  File ".../venv/local/lib/python2.7/site-packages/cairocffi/__init__.py", line 68, in _check_status
    raise exception(message, status)
cairocffi.CairoError: cairo returned CAIRO_STATUS_INVALID_MATRIX: invalid matrix (not invertible)

In images.py, RasterImage.draw, concrete_width and concrete_height both are zeros.

@SimonSapin
Copy link
Member

Does this happen with any image, or only this particular t.png image? If the latter, could you provide the image?

@lilydjwg
Copy link
Author

Any image. I've tried several, they all cause the error. Try my avatar on the left if you can't find one :-)

@SimonSapin
Copy link
Member

Thanks for the bug report! Version 0.23 is on PyPI and includes the fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants