Fixed: DecodeParms array support.

pull/1/head
Yusuke Shinyama 2014-07-09 19:07:27 +09:00
parent 137fc3a1ae
commit f5b5e31921
2 changed files with 8 additions and 6 deletions

View File

@ -71,7 +71,7 @@ class ImageWriter(object):
stream = image.stream
filters = stream.get_filters()
(width, height) = image.srcsize
if len(filters) == 1 and filters[0] in LITERALS_DCT_DECODE:
if len(filters) == 1 and filters[0][0] in LITERALS_DCT_DECODE:
ext = '.jpg'
elif (image.bits == 1 or
image.bits == 8 and image.colorspace in (LITERAL_DEVICE_RGB, LITERAL_DEVICE_GRAY)):

View File

@ -218,11 +218,14 @@ class PDFStream(PDFObject):
def get_filters(self):
filters = self.get_any(('F', 'Filter'))
params = self.get_any(('DP', 'DecodeParms', 'FDecodeParms'), {})
if not filters:
return []
if isinstance(filters, list):
return filters
return [filters]
if not isinstance(filters, list):
filters = [filters]
if not isinstance(params, list):
params = [params]
return zip(filters, params)
def decode(self):
assert self.data is None and self.rawdata is not None
@ -235,8 +238,7 @@ class PDFStream(PDFObject):
self.data = data
self.rawdata = None
return
for f in filters:
params = self.get_any(('DP', 'DecodeParms', 'FDecodeParms'), {})
for (f,params) in filters:
if f in LITERALS_FLATE_DECODE:
# will get errors if the document is encrypted.
try: