1
1
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:
Simon Sapin 2013-06-18 12:48:06 +01:00
parent dccd562c6b
commit e8fac4b840
2 changed files with 5 additions and 4 deletions

View File

@ -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:

View File

@ -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):