mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-05 08:27:22 +03:00
Fix #99: JPEG image not loading with cairo 1.8.x
This commit is contained in:
parent
dccd562c6b
commit
e8fac4b840
@ -17,6 +17,7 @@ import math
|
||||
|
||||
import cairocffi
|
||||
cairocffi.install_as_pycairo() # for CairoSVG
|
||||
CAIRO_HAS_MIME_DATA = cairocffi.cairo_version() >= 11000
|
||||
|
||||
import cairosvg.parser
|
||||
import cairosvg.surface
|
||||
@ -133,7 +134,7 @@ def get_image_from_uri(cache, url_fetcher, uri, forced_mime_type=None):
|
||||
'PNG and SVG are the only image formats available.')
|
||||
string = result.get('string') or result['file_obj'].read()
|
||||
surface, format_name = pixbuf.decode_to_image_surface(string)
|
||||
if format_name == 'jpeg':
|
||||
if format_name == 'jpeg' and CAIRO_HAS_MIME_DATA:
|
||||
surface.set_mime_data('image/jpeg', string)
|
||||
image = RasterImage(surface)
|
||||
finally:
|
||||
|
@ -14,7 +14,7 @@ from __future__ import division, unicode_literals
|
||||
|
||||
import io
|
||||
|
||||
import cairocffi as cairo
|
||||
import cairocffi
|
||||
import pytest
|
||||
|
||||
from .. import CSS
|
||||
@ -26,7 +26,7 @@ from .testing_utils import (
|
||||
@assert_no_logs
|
||||
def test_pdf_parser():
|
||||
fileobj = io.BytesIO()
|
||||
surface = cairo.PDFSurface(fileobj, 1, 1)
|
||||
surface = cairocffi.PDFSurface(fileobj, 1, 1)
|
||||
for width, height in [
|
||||
(100, 100),
|
||||
(200, 10),
|
||||
@ -298,7 +298,7 @@ def test_missing_links():
|
||||
|
||||
@assert_no_logs
|
||||
def test_jpeg():
|
||||
if not hasattr(cairo.ImageSurface, 'set_mime_data'):
|
||||
if cairocffi.cairo_version() < 11000:
|
||||
pytest.xfail()
|
||||
|
||||
def render(html):
|
||||
|
Loading…
Reference in New Issue
Block a user