ImageElement based on BufferedImage that stores decoded (uncompressed) image bitmap. It could occupy more then 50MB per image. And doesn't matter if it is JPEG or PNG.
To create PDImageXObject is used LosslessFactory. In this case compression not optimal at least for JPEG types.
Proposal:
Update ImageElement to use image source inputs stream or byte array (compressed).
To detect width and height just use ImageIO.getImageReaders(is)``, ``reader.getWidth(0), reader.getHeight(0)
Then on draw call PDImageXObject.createFromByteArray() - new method in PDFBox 2.0.8
Note:createFromByteArray() - it also not optimal due to reading all stream (one time) instead of parse only header to detect color space. Anyway stream / byte array is compressed it is better than BufferedImage
A few points about images
ImageElement
based onBufferedImage
that stores decoded (uncompressed) image bitmap. It could occupy more then 50MB per image. And doesn't matter if it is JPEG or PNG.PDImageXObject
is usedLosslessFactory
. In this case compression not optimal at least for JPEG types.Proposal:
ImageElement
to use image source inputs stream or byte array (compressed).ImageIO.getImageReaders(is)``, ``reader.getWidth(0)
,reader.getHeight(0)
PDImageXObject.createFromByteArray()
- new method inPDFBox 2.0.8
Note:
createFromByteArray()
- it also not optimal due to reading all stream (one time) instead of parse only header to detect color space. Anyway stream / byte array is compressed it is better thanBufferedImage