mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 01:34:24 +03:00
Added saving LA images as PDFs
This commit is contained in:
parent
c108d9ddb0
commit
0a0a3fc51f
|
@ -43,8 +43,9 @@ def test_save(tmp_path, mode):
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature("jpg_2000")
|
@skip_unless_feature("jpg_2000")
|
||||||
def test_save_rgba(tmp_path):
|
@pytest.mark.parametrize("mode", ("LA", "RGBA"))
|
||||||
helper_save_as_pdf(tmp_path, "RGBA")
|
def test_save_alpha(tmp_path, mode):
|
||||||
|
helper_save_as_pdf(tmp_path, mode)
|
||||||
|
|
||||||
|
|
||||||
def test_monochrome(tmp_path):
|
def test_monochrome(tmp_path):
|
||||||
|
@ -57,8 +58,8 @@ def test_monochrome(tmp_path):
|
||||||
|
|
||||||
|
|
||||||
def test_unsupported_mode(tmp_path):
|
def test_unsupported_mode(tmp_path):
|
||||||
im = hopper("LA")
|
im = hopper("PA")
|
||||||
outfile = str(tmp_path / "temp_LA.pdf")
|
outfile = str(tmp_path / "temp_PA.pdf")
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
im.save(outfile)
|
im.save(outfile)
|
||||||
|
|
|
@ -1486,7 +1486,7 @@ files. Different encoding methods are used, depending on the image mode.
|
||||||
unavailable
|
unavailable
|
||||||
* L, RGB and CMYK mode images use JPEG encoding
|
* L, RGB and CMYK mode images use JPEG encoding
|
||||||
* P mode images use HEX encoding
|
* P mode images use HEX encoding
|
||||||
* RGBA mode images use JPEG2000 encoding
|
* LA and RGBA mode images use JPEG2000 encoding
|
||||||
|
|
||||||
.. _pdf-saving:
|
.. _pdf-saving:
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,11 @@ def _save(im, fp, filename, save_all=False):
|
||||||
# params = f"<< /Predictor 15 /Columns {width-2} >>"
|
# params = f"<< /Predictor 15 /Columns {width-2} >>"
|
||||||
colorspace = PdfParser.PdfName("DeviceGray")
|
colorspace = PdfParser.PdfName("DeviceGray")
|
||||||
procset = "ImageB" # grayscale
|
procset = "ImageB" # grayscale
|
||||||
|
elif im.mode == "LA":
|
||||||
|
filter = "JPXDecode"
|
||||||
|
# params = f"<< /Predictor 15 /Columns {width-2} >>"
|
||||||
|
colorspace = PdfParser.PdfName("DeviceGray")
|
||||||
|
procset = "ImageB" # grayscale
|
||||||
elif im.mode == "P":
|
elif im.mode == "P":
|
||||||
filter = "ASCIIHexDecode"
|
filter = "ASCIIHexDecode"
|
||||||
palette = im.getpalette()
|
palette = im.getpalette()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user