Aspose.Imaging-for-Java中com.aspose.imaging.FileFormat为0是什么格式?遇到了一个tiff,转为图片时出现:com.aspose.imaging.coreexceptions.ImageSaveException: Image export failed. —> class com.aspose.imaging.coreexceptions.FrameworkException: Cannot parse file. —> class com.aspose.imaging.coreexceptions.ImageLoadException: Not a jpeg data
代码是:
TiffImage tifImage = (TiffImage) Image.load(fromPath);
TiffFrame[] frames = tifImage.getFrames();
TiffFrame frame = frames[i];
frame.save(“F:/a.jpg”);
frame.save时报以上异常。想问下com.aspose.imaging.FileFormat为0是什么格式?有没有列表可查看long值对应的格式
@aaaConvert
你好!. 错误的原因是框架#5已损坏,没有查看器可以打开它。 要变通解决此问题,请使用try/catch构造,如示例中所示。
LoadOptions options = new LoadOptions();
options.setDataRecoveryMode(DataRecoveryMode.MaximalRecover);
try (TiffImage tifImage = (TiffImage) Image.load("200704080006000131.Tif", options))
{
TiffFrame[] frames = tifImage.getFrames();
int i = 0;
for (TiffFrame frame : frames)
{
try
{
frame.save("frame_" + i + ".jpg", new JpegOptions());
}
catch (RuntimeException exc)
{
// Corrupted frame, just skip it
}
i++;
}
}