Factory factory = Factory.getInstance();
Canvas canvas = factory.createCanvas();
Desktop desktop = factory.createDesktop();
Blob blob = canvas.encode();
BlobMetaData metaData = desktop.extractMetaData(blob);
assertEquals("image/png", metaData.getMimeType());
assertEquals(canvas.getWidth(), metaData.getImageWidth());
assertEquals(canvas.getHeight(), metaData.getImageHeight());
blob = canvas.encode("image/png");
metaData = desktop.extractMetaData(blob);
assertEquals("image/png", metaData.getMimeType());
assertEquals(canvas.getWidth(), metaData.getImageWidth());
assertEquals(canvas.getHeight(), metaData.getImageHeight());
blob = canvas.encode("image/jpeg");
metaData = desktop.extractMetaData(blob);
assertEquals("image/jpeg", metaData.getMimeType());
assertEquals(canvas.getWidth(), metaData.getImageWidth());
assertEquals(canvas.getHeight(), metaData.getImageHeight());
try {
canvas.encode("image/gif");
fail();
} catch (JavaScriptException jse) {