diff --git a/scss/extension/compass/images.py b/scss/extension/compass/images.py index b2f33f1f..8ef5b8b6 100644 --- a/scss/extension/compass/images.py +++ b/scss/extension/compass/images.py @@ -124,6 +124,7 @@ def _image_url(path, only_path=False, cache_buster=True, dst_color=None, src_col image = Image.open(path) except IOError: if not collapse_x and not collapse_y and not dst_colors: + path.seek(0) simply_process = True if simply_process: diff --git a/scss/tests/extension/compass/test_images.py b/scss/tests/extension/compass/test_images.py index 025a32e4..69e6e3c9 100644 --- a/scss/tests/extension/compass/test_images.py +++ b/scss/tests/extension/compass/test_images.py @@ -45,6 +45,14 @@ def test_inline_image(calc, monkeypatch): font_base64 = f.read() assert 'url(data:image/png;base64,%s)' % font_base64 == calc('inline_image("/test-qr.png")').render() +@needs_PIL +def test_inline_plaintext_image(calc, monkeypatch): + monkeypatch.setattr(config, 'IMAGES_ROOT', os.path.join(config.PROJECT_ROOT, 'tests/files/images')) + + with open(os.path.join(config.PROJECT_ROOT, 'tests/files/images/test-svg.base64.txt'), 'r') as f: + svg_base64 = f.read() + assert 'url(data:image/svg+xml;base64,%s)' % svg_base64 == calc('inline_image("/test-svg.svg")').render() + @pytest.mark.skipif(sys.platform == 'win32', reason='cur mimetype is defined on windows') @needs_PIL diff --git a/scss/tests/files/images/test-svg.base64.txt b/scss/tests/files/images/test-svg.base64.txt new file mode 100644 index 00000000..7e176a2c --- /dev/null +++ b/scss/tests/files/images/test-svg.base64.txt @@ -0,0 +1 @@ +PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIxMDBweCINCgkgaGVpZ2h0PSIxMDBweCIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPC9zdmc+DQo= \ No newline at end of file diff --git a/scss/tests/files/images/test-svg.svg b/scss/tests/files/images/test-svg.svg new file mode 100644 index 00000000..8a389164 --- /dev/null +++ b/scss/tests/files/images/test-svg.svg @@ -0,0 +1,5 @@ + + + +