JavaImageIOMigrate implements Migrate { public MigrateResult migrate(DigitalObject dob, URI inputFormat, URI outputFormat, List<Parameter> parameters) { ServicePerformanceHelper sph = new ServicePerformanceHelper(); BufferedImage image = null; if( dob.getContent() == null ) { return this.returnWithErrorMessage("The Content of the DigitalObject should not be NULL.", null); } try { image = ImageIO.read( dob.getContent().getInputStream() ); } catch ( Exception e) { return returnWithErrorMessage("Exception reading the image - unsupported or invalid input? ", e); } sph.loaded(); if( image == null ) { return returnWithErrorMessage("Failed to read the image - unsupported or invalid input? ", null); } Set<String> extensionsForURI = format.getExtensions(outputFormat); if(extensionsForURI.isEmpty() ) { return this.returnWithErrorMessage("Unsupported output format: "+outputFormat,null); } else { log.info("Outputing image to format: "+format.getExtensions(outputFormat).iterator().next()); } String extension = extensionsForURI.iterator().next(); File outfile = null; try { outfile = File.createTempFile("imageio", extension); ImageIO.write(image, extension, outfile ); } catch ( Exception e) { return this.returnWithErrorMessage("Could not create image in the new format. ",e); } ServiceReport rep = new ServiceReport(Type.INFO, Status.SUCCESS, "OK", sph.getPerformanceProperties() ); DigitalObject ndo = new DigitalObject.Builder(Content.byReference(outfile)).build(); return new MigrateResult(ndo, rep); }  ServiceDescription describe(); MigrateResult migrate(DigitalObject dob, URI inputFormat,
            URI outputFormat, List<Parameter> parameters); static final String NAME; }
@Test public void testMigrate() throws IOException { this.migrateTo("gif"); this.migrateTo("jpg"); }