mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
Do not set ColorSpace for JPXDecode since it is optional
This commit is contained in:
parent
ddfb7ef14b
commit
6ca38552c9
|
@ -152,17 +152,17 @@ def _save(im, fp, filename, save_all=False):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
filter = "DCTDecode"
|
filter = "DCTDecode"
|
||||||
colorspace = PdfParser.PdfName("DeviceGray")
|
dict_obj["ColorSpace"] = PdfParser.PdfName("DeviceGray")
|
||||||
procset = "ImageB" # grayscale
|
procset = "ImageB" # grayscale
|
||||||
elif im.mode == "L":
|
elif im.mode == "L":
|
||||||
filter = "DCTDecode"
|
filter = "DCTDecode"
|
||||||
# params = f"<< /Predictor 15 /Columns {width-2} >>"
|
# params = f"<< /Predictor 15 /Columns {width-2} >>"
|
||||||
colorspace = PdfParser.PdfName("DeviceGray")
|
dict_obj["ColorSpace"] = PdfParser.PdfName("DeviceGray")
|
||||||
procset = "ImageB" # grayscale
|
procset = "ImageB" # grayscale
|
||||||
elif im.mode == "P":
|
elif im.mode == "P":
|
||||||
filter = "ASCIIHexDecode"
|
filter = "ASCIIHexDecode"
|
||||||
palette = im.getpalette()
|
palette = im.getpalette()
|
||||||
colorspace = [
|
dict_obj["ColorSpace"] = [
|
||||||
PdfParser.PdfName("Indexed"),
|
PdfParser.PdfName("Indexed"),
|
||||||
PdfParser.PdfName("DeviceRGB"),
|
PdfParser.PdfName("DeviceRGB"),
|
||||||
255,
|
255,
|
||||||
|
@ -171,16 +171,15 @@ def _save(im, fp, filename, save_all=False):
|
||||||
procset = "ImageI" # indexed color
|
procset = "ImageI" # indexed color
|
||||||
elif im.mode == "RGB":
|
elif im.mode == "RGB":
|
||||||
filter = "DCTDecode"
|
filter = "DCTDecode"
|
||||||
colorspace = PdfParser.PdfName("DeviceRGB")
|
dict_obj["ColorSpace"] = PdfParser.PdfName("DeviceRGB")
|
||||||
procset = "ImageC" # color images
|
procset = "ImageC" # color images
|
||||||
elif im.mode == "RGBA":
|
elif im.mode == "RGBA":
|
||||||
filter = "JPXDecode"
|
filter = "JPXDecode"
|
||||||
colorspace = PdfParser.PdfName("DeviceRGB")
|
|
||||||
procset = "ImageC" # color images
|
procset = "ImageC" # color images
|
||||||
dict_obj["SMaskInData"] = 1
|
dict_obj["SMaskInData"] = 1
|
||||||
elif im.mode == "CMYK":
|
elif im.mode == "CMYK":
|
||||||
filter = "DCTDecode"
|
filter = "DCTDecode"
|
||||||
colorspace = PdfParser.PdfName("DeviceCMYK")
|
dict_obj["ColorSpace"] = PdfParser.PdfName("DeviceCMYK")
|
||||||
procset = "ImageC" # color images
|
procset = "ImageC" # color images
|
||||||
decode = [1, 0, 1, 0, 1, 0, 1, 0]
|
decode = [1, 0, 1, 0, 1, 0, 1, 0]
|
||||||
else:
|
else:
|
||||||
|
@ -232,7 +231,6 @@ def _save(im, fp, filename, save_all=False):
|
||||||
Filter=filter,
|
Filter=filter,
|
||||||
Decode=decode,
|
Decode=decode,
|
||||||
DecodeParms=params,
|
DecodeParms=params,
|
||||||
ColorSpace=colorspace,
|
|
||||||
**dict_obj,
|
**dict_obj,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user