Different Behavior Between The Same Code In Java Application & Smart Service

Hi All,

I've created a smart service that takes as input a document - image - of type jpg, png, tiff and converts the image to another of the other previously listed formats.

My standalone Java application - that the smart service is based on - successfully converts any format to any other format.

My smart service produces the following outputs:

- jpg => png - Success
- png => jpg - Success
- tiff => png - Failure
- tiff => jpg Failure

To do this conversion I'm using the library JAI ImageIO Core - github.com/.../jai-imageio-core.

I've figured out where in the smart service this fails on .tiff images but not other forms; I just have no idea why.

In both the standalone application and my smart service, the buffered image is created like follows:

BufferedImage bufferedImage = ImageIO.read(imageFile);

Where imageFile is a variable of type File. The onl...

OriginalPostID-261516

  Discussion posts and replies are publicly visible

  • ...y difference between the standalone application and smart service is how we get this file. In the smart service I'm getting it as follows:

    private Long originalImage;

    String filepath = this.contentService.getInternalFilename(originalImage);
    Document originalDocument = (Document) this.contentService.getVersion(originalImage, ContentConstants.VERSION_CURRENT);
    File imageFile = new File(filepath);
    BufferedImage bufferedImage = ImageIO.read(imageFile);

    So at this point we have a BufferedImage.

    In my smart service, when passing a tiff image as input to convert, my BufferedImage is null, however for jpg and png it is created successfully.

    In my standalone application the Buffered Image is created successfully with a tiff image as input.

    Buffer Image representation in the smart service looks like this on a jpg/png:

    bufferedImage = BufferedImage@4c454e25: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@7c906947 tran...
  • ...sparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 3264 height = 2448 #numDataElements 3 dataOff[0] = 2

    But like follows on a tiff:

    bufferedImage = null

    So my question is, why does this code work fine in a standalone Java application but not while the exact same code is in a smart service?

    Something deeper must be happening here - than just at a code level - because my smart service works fine on jpg and png images, but fails on tiff.

    Any help would be appreciated.

    Thanks.
  • Can you verify that the jai-imageio-core library has been added in the META_INF/lib folder of the Java plug-in project? Curious if it is being deployed along with your plug-in since it's working on the file types supported by Java's base ImageIO but not on tiffs which are part of the jai-imageio-core library.
  • matts, so it turns out I wasn't actually using the library. A newer version of the JDK (was using 1.8.0_74, now using 1.8.0_111) handles .tif images in javax.imageio.Read().

    So, updating the server JDK now results in .tif images being converted successful and my plugin no longer relies an an external library.

    Cheers.