大佬国庆快乐!
看了一遍,好像jbig2格式不支持。
github.com/caj2pdf/caj2pdf
jbig2dec.py解码jbig2格式, jbigdec.py解码jbig格式
该项目下的jbig2dec.py, jbigdec.py可以正常调用,只需略加修改,以jbig2dec.py为例(jbigdec.py相同修改)
[Python] 纯文本查看 复制代码 class CImage:
# 入参修改
def __init__(self, buffer, width, height, bits_per_pixel):
self.buffer = buffer
self.buffer_size=len(buffer)
# (self.width, self.height,
# self.num_planes, self.bits_per_pixel) = struct.unpack("<IIHH", buffer[4:16])
# 修改
self.width = width
self.height = height
self.bits_per_pixel = bits_per_pixel
self.bytes_per_line = ((self.width * self.bits_per_pixel + 31) >> 5) << 2
def DecodeJbig2(self):
out = create_string_buffer(self.height * self.bytes_per_line)
width_in_bytes = (self.width * self.bits_per_pixel + 7) >> 3
# decode_jbig2data_c(self.buffer[48:], self.buffer_size-48, out, self.width, self.height, self.bytes_per_line, width_in_bytes)
# 修改
decode_jbig2data_c(self.buffer, self.buffer_size, out, self.width, self.height, self.bytes_per_line, width_in_bytes)
return out |