Pictures.add Problem

Hi,
The method is throwing unsupported format exception(.jpg) from Linux box whereas it works fine with windows.It doesn’t recognize the path either when the parameter is String or InputStream.Is there any special operation needed when you run it from Linux.

Also one more doubt is will it be added if the image is part of classpath.

Thanks
Joe

Hi Joe,

Which linux JDK do you use? Could you list your environment and your picture file?

In Aspose.Cells for java, we use the following codes to get the image file format:

ImageInputStream iis = javax.imageio.ImageIO.createImageInputStream(stream);
Iterator it = javax.imageio.ImageIO.getImageReaders(iis);

if(it.hasNext()){
String formatName = it.next().getFormatName();

System.out.println(formatName);

}

Please post the running result.

Hi,

The linux jdk is 1.4.2_05.The picture file is of format .jpg.

Java Environment

Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)

Output and Exceptions are below

Format Name is:JPEG

Exception Trace

java.io.IOException: Resetting to invalid mark
at java.io.BufferedInputStream.reset(BufferedInputStream.java:370)
at com.aspose.cells.H.a(Unknown Source)
at com.aspose.cells.H.a(Unknown Source)

at com.aspose.cells.bO.a(Unknown Source)

at com.aspose.cells.Picture.(Unknown Source)
at com.aspose.cells.Pictures.add(Unknown Source)
at java.lang.Thread.run(Thread.java:534)
java.lang.IllegalArgumentException: Unsupported image foramt.
at com.aspose.cells.Picture.(Unknown Source)
at com.aspose.cells.Pictures.add(Unknown Source)

Please let me know about this.since this is being a big issue for us.Also one more thing it gives same issue when i load the image using classpath

Regards

Joe

Hi Joe,

I have tested com.aspose.cells.Pictures.add() with j2sdk1.4.2_05 for linux, it works fine with jpg image. Please check your image file, is it a valid jpg format image? Or, please post your sample code and image, we will check it for detail.

Hi John,

Thanks for the reply.It worked i just changed the Inputstream to ByteArrayInputStream and it takes now and it works perfect.

Regards

Joe

Hi,

There is an issue while using InputStream directly to the method.

java.io.IOException: Resetting to invalid mark

at java.io.BufferedInputStream.reset(BufferedInputStream.java:370)

It resets the stream before reading the full contents of the image.Just try with InputStream to add an image it will throw you an error.

Thanks

Joe

Hi Joe,

Please try this fix