25 lines
885 B
Python
25 lines
885 B
Python
from ..utils import Bbox
|
|
from ..interpreter.PDFStream import PDFStream
|
|
from ._base import LTComponent
|
|
|
|
## LTImage
|
|
##
|
|
class LTImage(LTComponent):
|
|
|
|
def __init__(self, name: str, stream: PDFStream, bbox: Bbox):
|
|
LTComponent.__init__(self, bbox)
|
|
self.name = name
|
|
self.stream = stream
|
|
self.srcsize = (stream.get_any(('W', 'Width')),
|
|
stream.get_any(('H', 'Height')))
|
|
self.imagemask = stream.get_any(('IM', 'ImageMask'))
|
|
self.bits = stream.get_any(('BPC', 'BitsPerComponent'), 1)
|
|
self.colorspace = stream.get_any(('CS', 'ColorSpace'))
|
|
if not isinstance(self.colorspace, list):
|
|
self.colorspace = [self.colorspace]
|
|
return
|
|
|
|
def __repr__(self):
|
|
return ('<%s(%s) %s %r>' %
|
|
(self.__class__.__name__, self.name,
|
|
str(self.bbox), self.srcsize)) |