net.coobird.thumbnailator.tasks.UnsupportedFormatException: No suitable ImageReader found for source data. at net.coobird.thumbnailator.tasks.io.InputStreamImageSource.read(Unknown Source) at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.read(Unknown Source) at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source) at net.coobird.thumbnailator.Thumbnails$Builder.toOutputStream(Unknown Source)
处理代码如下:
Blob zp = rs.getBlob("swry_zp"); if(zp!=null){ is=zp.getBinaryStream(); if (null != is) { baos = new ByteArrayOutputStream(); //对图片进行压缩处理 Thumbnails.of(is).forceSize(98, 137).toOutputStream(baos); //将照片进行Base64转码 sy.setSwry_zp(Base64.encodeBase64String(baos.toByteArray())); } }
从oracle中读出照片信息,照片以blog格式存储,然后以Base64编码返回给客户端,以上错误信息只是在获取某些照片信息时报错,有些照片
这种方式处理是没有问题的.当前是:
Thumbnails.of(is).forceSize(98, 137).toOutputStream(baos);抛出IO异常,然后rs就中断了:
while(rs.next()){}
其源码中抛出此异常的代码段如下:
public BufferedImage read() throws IOException { ImageInputStream iis = ImageIO.createImageInputStream(is); if (iis == null) { throw new IOException("Could not open InputStream."); } Iterator<ImageReader> readers = ImageIO.getImageReaders(iis); if (!readers.hasNext()) { throw new UnsupportedFormatException( UnsupportedFormatException.UNKNOWN, "No suitable ImageReader found for source data." ); } ImageReader reader = readers.next(); reader.setInput(iis); inputFormatName = reader.getFormatName(); BufferedImage img = reader.read(FIRST_IMAGE_INDEX); iis.close(); return img; }
具体原因还没有找出,
时间: 2024-10-12 03:03:13