@Test(dataProvider = "createImagesWithCompressionOptions", enabled = true) public void testImageWriterCompression(final RenderedImage im, final String compressionType, final float compressionQuality, final String outputName) throws IOException { final String extension = outputName.substring(outputName.lastIndexOf(".") + 1); final ImageWriter imgWriter = ImageIO.getImageWritersByFormatName(extension).next(); final ImageWriteParam imgWriteParams = new WebPWriteParam(null); imgWriteParams.setCompressionType(compressionType); imgWriteParams.setCompressionQuality(compressionQuality); final String testName = "CompressionOptions"; final File file = createOutputFile(testName, outputName); final ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(file); try { imgWriter.setOutput(imageOutputStream); imgWriter.write(null, new IIOImage(im, null, null), imgWriteParams); final int length = (int) imageOutputStream.length(); assertTrue(length > 0); } finally { try { imageOutputStream.close(); } catch (final IOException e) { } } }
@Override public void write( IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param ) throws IOException { if ( param == null ) { param = getDefaultWriteParam(); } WebPWriteParam writeParam = (WebPWriteParam) param; ImageOutputStream output = ( ImageOutputStream ) getOutput(); RenderedImage ri = image.getRenderedImage(); byte[] encodedData = WebP.encode(writeParam, ri); output.write( encodedData ); }
WebPWriter extends ImageWriter { @Override public void write( IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param ) throws IOException { if ( param == null ) { param = getDefaultWriteParam(); } WebPWriteParam writeParam = (WebPWriteParam) param; ImageOutputStream output = ( ImageOutputStream ) getOutput(); RenderedImage ri = image.getRenderedImage(); byte[] encodedData = WebP.encode(writeParam, ri); output.write( encodedData ); } }
WebPWriter extends ImageWriter { @Override public void write( IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param ) throws IOException { if ( param == null ) { param = getDefaultWriteParam(); } WebPWriteParam writeParam = (WebPWriteParam) param; ImageOutputStream output = ( ImageOutputStream ) getOutput(); RenderedImage ri = image.getRenderedImage(); byte[] encodedData = WebP.encode(writeParam, ri); output.write( encodedData ); } WebPWriter( ImageWriterSpi originatingProvider ); }
WebPWriter extends ImageWriter { @Override public void write( IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param ) throws IOException { if ( param == null ) { param = getDefaultWriteParam(); } WebPWriteParam writeParam = (WebPWriteParam) param; ImageOutputStream output = ( ImageOutputStream ) getOutput(); RenderedImage ri = image.getRenderedImage(); byte[] encodedData = WebP.encode(writeParam, ri); output.write( encodedData ); } WebPWriter( ImageWriterSpi originatingProvider ); @Override ImageWriteParam getDefaultWriteParam(); @Override IIOMetadata convertImageMetadata( IIOMetadata inData, ImageTypeSpecifier imageType, ImageWriteParam param ); @Override IIOMetadata convertStreamMetadata( IIOMetadata inData, ImageWriteParam param ); @Override IIOMetadata getDefaultImageMetadata( ImageTypeSpecifier imageType, ImageWriteParam param ); @Override IIOMetadata getDefaultStreamMetadata( ImageWriteParam param ); @Override void write( IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param ); }
WebPWriter extends ImageWriter { @Override public void write( IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param ) throws IOException { if ( param == null ) { param = getDefaultWriteParam(); } WebPWriteParam writeParam = (WebPWriteParam) param; ImageOutputStream output = ( ImageOutputStream ) getOutput(); RenderedImage ri = image.getRenderedImage(); byte[] encodedData = WebP.encode(writeParam, ri); output.write( encodedData ); } WebPWriter( ImageWriterSpi originatingProvider ); @Override ImageWriteParam getDefaultWriteParam(); @Override IIOMetadata convertImageMetadata( IIOMetadata inData, ImageTypeSpecifier imageType, ImageWriteParam param ); @Override IIOMetadata convertStreamMetadata( IIOMetadata inData, ImageWriteParam param ); @Override IIOMetadata getDefaultImageMetadata( ImageTypeSpecifier imageType, ImageWriteParam param ); @Override IIOMetadata getDefaultStreamMetadata( ImageWriteParam param ); @Override void write( IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param );  }