> On 27 Apr 2015, at 08:52, Tilman Hausherr <[email protected]> wrote: > > PDImageXObject pdImage; > if (imagePath.toLowerCase().endsWith(".jpg")) > { > pdImage = JPEGFactory.createFromStream(doc, new > FileInputStream(imagePath)); > } > else if (imagePath.toLowerCase().endsWith(".tif") || > imagePath.toLowerCase().endsWith(".tiff")) > { > pdImage = CCITTFactory.createFromFile(doc, new > File(imagePath)); > } > else if (imagePath.toLowerCase().endsWith(".gif") || > imagePath.toLowerCase().endsWith(".bmp") || > imagePath.toLowerCase().endsWith(".png")) > { > BufferedImage bim = ImageIO.read(new File(imagePath)); > pdImage = LosslessFactory.createFromImage(doc, bim); > } > else > { > throw new IOException("Image type not supported: " + > imagePath); > }
Tilman, maybe we could encapsulate this code in a static factory method, e.g. PDImageXObject.load(File)? — John

