From e305af104b945fc1beba9ca25c56f9c93e3c042c Mon Sep 17 00:00:00 2001 From: Isaiah Savage Date: Tue, 16 Jan 2024 14:24:42 -0500 Subject: [PATCH] change default export format Signed-off-by: Isaiah Savage --- SlideExtractor.java | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/SlideExtractor.java b/SlideExtractor.java index 268d816..5298e76 100644 --- a/SlideExtractor.java +++ b/SlideExtractor.java @@ -19,12 +19,12 @@ public static void usage() { System.out.println("Usage: slideextractor "); } - public static void main (String[] args) throws FileNotFoundException, IOException, IllegalArgumentException { - if (args.length == 0) { + public static void main(String[] args) throws FileNotFoundException, IOException, IllegalArgumentException { + if (args.length == 0) { usage(); return; } - + System.out.println(args[0]); System.out.println("User Working Dir: " + System.getProperty("user.dir")); String classpath = System.getProperty("java.class.path"); @@ -37,27 +37,28 @@ public static void main (String[] args) throws FileNotFoundException, IOExceptio Dimension pgsize = pptx.getPageSize(); int idx = 1; - String output_image_format = "png"; - if (args.length == 2) { - output_image_format = args[1].toLowerCase(); - } - - if (!output_image_format.equals("png") && !output_image_format.equals("jpeg") && !output_image_format.equals("gif")) { + String output_image_format = "jpeg"; + if (args.length == 2) { + output_image_format = args[1].toLowerCase(); + } + + if (!output_image_format.equals("png") && !output_image_format.equals("jpeg") + && !output_image_format.equals("gif")) { throw new IllegalArgumentException("Invalid output format" + output_image_format); } for (XSLFSlide slide : pptx.getSlides()) { BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); - + // clear the drawing area - graphics.setPaint(Color.white); - graphics.fill(new Rectangle2D.Double(0, 0, pgsize.width, pgsize.height)); + graphics.setPaint(Color.white); + graphics.fill(new Rectangle2D.Double(0, 0, pgsize.width, pgsize.height)); - //render + // render slide.draw(graphics); - - //save the output + + // save the output FileOutputStream out = new FileOutputStream("slide-" + idx + "." + output_image_format); javax.imageio.ImageIO.write(img, output_image_format, out); out.close(); @@ -67,5 +68,5 @@ public static void main (String[] args) throws FileNotFoundException, IOExceptio is.close(); return; - } + } }