1

MTOM is usually used to transfer image data over SOAP (attachments). The image is mapped to a java.awt.Image (at least with CXF). Does the Image object consume a lot more memory than the actual image transferred? Let's say a transferred JPEG is 10MB, how much more space will the Image object consume?

Marcel Stör
  • 22,695
  • 19
  • 92
  • 198
  • 3
    It's most likely that the Java Image is uncompressed. But it also depends, as `java.awt.Image` can be unbuffered, meaning that until it's actually required, it may not be loaded (but in your case I doubt that's the case). The other problem is, `java.awt.Image` is an abstract class, so unless you know what the implementation is doing, it's difficult to say either way – MadProgrammer Sep 19 '12 at 05:27
  • @MadProgrammer, it's a buffered image: BufferedImage@5c799c7a: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@49a695dc transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 8268 height = 5839 #numDataElements 3 dataOff[0] = 2 – Marcel Stör Sep 20 '12 at 06:57
  • You can't depend on the implementation, but the original statement stands. It's likely that the image data is uncompressed – MadProgrammer Sep 20 '12 at 07:08

1 Answers1

4

Does the Image object consume a lot more memory than the actual image transferred?

Typically yes. The idea of most of the file formats is to compress image data.

Let's say a transferred JPEG is 10MB, how much more space will the Image object consume?

The RAM size depends on W * H * 'pixel depth'. E.G. RGBA in 256 shades is 4 bytes per pixel. JPEG does not support alpha transparency, so it would be 3 bytes per pixel.


For some idea of the effectiveness of JPEG compression efficiency at different levels, see this answer:

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • ... and I don't believe there is a direct relationship between jpeg file size and those dimensions. (Doesn't jpeg use lossy compression?) – Stephen C Sep 19 '12 at 05:45
  • @StephenC I think the answer linked in the edit should clarify a few things. And yes, definitely lossy. The 3rd image above at 80% quality(/20% compression) is the JPEG. It is not as crisp as the first two images, yet still larger in bytes than the PNG (2nd image). – Andrew Thompson Sep 19 '12 at 05:54