mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-29 02:03:25 +03:00
Do not set BitsPerComponent for JPXDecode since it is ignored
This commit is contained in:
parent
022e650d18
commit
ddfb7ef14b
|
@ -125,20 +125,19 @@ def _save(im, fp, filename, save_all=False):
|
||||||
# (packbits) or LZWDecode (tiff/lzw compression). Note that
|
# (packbits) or LZWDecode (tiff/lzw compression). Note that
|
||||||
# PDF 1.2 also supports Flatedecode (zip compression).
|
# PDF 1.2 also supports Flatedecode (zip compression).
|
||||||
|
|
||||||
bits = 8
|
|
||||||
params = None
|
params = None
|
||||||
decode = None
|
decode = None
|
||||||
smaskindata = 0
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Get image characteristics
|
# Get image characteristics
|
||||||
|
|
||||||
width, height = im.size
|
width, height = im.size
|
||||||
|
|
||||||
|
dict_obj = {"BitsPerComponent": 8}
|
||||||
if im.mode == "1":
|
if im.mode == "1":
|
||||||
if features.check("libtiff"):
|
if features.check("libtiff"):
|
||||||
filter = "CCITTFaxDecode"
|
filter = "CCITTFaxDecode"
|
||||||
bits = 1
|
dict_obj["BitsPerComponent"] = 1
|
||||||
params = PdfParser.PdfArray(
|
params = PdfParser.PdfArray(
|
||||||
[
|
[
|
||||||
PdfParser.PdfDict(
|
PdfParser.PdfDict(
|
||||||
|
@ -178,7 +177,7 @@ def _save(im, fp, filename, save_all=False):
|
||||||
filter = "JPXDecode"
|
filter = "JPXDecode"
|
||||||
colorspace = PdfParser.PdfName("DeviceRGB")
|
colorspace = PdfParser.PdfName("DeviceRGB")
|
||||||
procset = "ImageC" # color images
|
procset = "ImageC" # color images
|
||||||
smaskindata = 1
|
dict_obj["SMaskInData"] = 1
|
||||||
elif im.mode == "CMYK":
|
elif im.mode == "CMYK":
|
||||||
filter = "DCTDecode"
|
filter = "DCTDecode"
|
||||||
colorspace = PdfParser.PdfName("DeviceCMYK")
|
colorspace = PdfParser.PdfName("DeviceCMYK")
|
||||||
|
@ -206,6 +205,7 @@ def _save(im, fp, filename, save_all=False):
|
||||||
elif filter == "DCTDecode":
|
elif filter == "DCTDecode":
|
||||||
Image.SAVE["JPEG"](im, op, filename)
|
Image.SAVE["JPEG"](im, op, filename)
|
||||||
elif filter == "JPXDecode":
|
elif filter == "JPXDecode":
|
||||||
|
del dict_obj["BitsPerComponent"]
|
||||||
Image.SAVE["JPEG2000"](im, op, filename)
|
Image.SAVE["JPEG2000"](im, op, filename)
|
||||||
elif filter == "FlateDecode":
|
elif filter == "FlateDecode":
|
||||||
ImageFile._save(im, op, [("zip", (0, 0) + im.size, 0, im.mode)])
|
ImageFile._save(im, op, [("zip", (0, 0) + im.size, 0, im.mode)])
|
||||||
|
@ -230,11 +230,10 @@ def _save(im, fp, filename, save_all=False):
|
||||||
Width=width, # * 72.0 / x_resolution,
|
Width=width, # * 72.0 / x_resolution,
|
||||||
Height=height, # * 72.0 / y_resolution,
|
Height=height, # * 72.0 / y_resolution,
|
||||||
Filter=filter,
|
Filter=filter,
|
||||||
BitsPerComponent=bits,
|
|
||||||
Decode=decode,
|
Decode=decode,
|
||||||
DecodeParms=params,
|
DecodeParms=params,
|
||||||
ColorSpace=colorspace,
|
ColorSpace=colorspace,
|
||||||
SMaskInData=smaskindata,
|
**dict_obj,
|
||||||
)
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue
Block a user