[reportlab-users] Image compression
Robin Becker
robin at reportlab.com
Fri Nov 16 05:16:47 EST 2007
Farid Adigamov wrote:
> Hello!
>
> Is there any trick to switch off image compression?
> Thanks.
>
.......
We have an environment variable called RL_pageCompression that turns on and off
the stream compression, but I think the image compression is done
unconditionally except for natively handled jpegs. I can probably add an extra
flag if you really want. If you're just experimenting then this method in
pdfdoc.py should be modified
def loadImageFromSRC(self, im):
"Extracts the stream, width and height"
fp = im.jpeg_fh()
if fp:
self.loadImageFromJPEG(fp)
else:
zlib = import_zlib()
if not zlib: return
self.width, self.height = im.getSize()
raw = im.getRGBData()
assert(len(raw) == self.width*self.height, "Wrong amount of data
for image")
- self.streamContent = pdfutils._AsciiBase85Encode(zlib.compress(raw))
+ self.streamContent = pdfutils._AsciiBase85Encode(raw)
self.colorSpace= _mode2CS[im.mode]
self.bitsPerComponent = 8
- self._filters = 'ASCII85Decode','FlateDecode' #'A85','Fl'
+ self._filters = 'ASCII85Decode',
self._checkTransparency(im)
that will stop the compression for most images, but the image data is still
ascii 85 encoded. If you don't even want A85 then I think you're liable to get
problems, but the change should be obvious.
--
Robin Becker
More information about the reportlab-users
mailing list