From 5c858db2917d787fc61f4a47ccc991af1d248085 Mon Sep 17 00:00:00 2001
From: ulrich <not disclosed>
Date: Sun, 14 Jan 2018 12:59:18 +0000
Subject: [PATCH] Erlaeuterungen zu kleiner.sh erweitert; Qualitaet bei der Bilderausgabe hinzugefuegt

---
 src/bilder.groovy |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/bilder.groovy b/src/bilder.groovy
index cef6dd3..90294bd 100644
--- a/src/bilder.groovy
+++ b/src/bilder.groovy
@@ -14,6 +14,10 @@
 import java.net.FileNameMap;
 import java.net.URLConnection;
 import javax.imageio.ImageIO;
+import javax.imageio.ImageWriter;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.stream.FileImageOutputStream;
+import javax.imageio.IIOImage;
 import java.lang.Integer;
 
 /*
@@ -46,7 +50,7 @@
       mediaTracker.waitForID(0);
       if (!mediaTracker.isErrorAny()) {
 
-        int quality = Integer.parseInt(args[1]);
+        float quality = Float.parseFloat(args[1]);
         float factor = (float) 0.0;
 
         BufferedImage thumbImage;
@@ -123,7 +127,21 @@
           imgType = "jpg";
         }
 
-        ImageIO.write(thumbImage, imgType, outFile);
+        //ImageIO.write(thumbImage, imgType, outFile);
+
+				/* 14.1.2018 Beginn */
+				//File outfile =new File(“/opt/images/modified.jpg”);
+        ImageWriter writer = ImageIO.getImageWritersByFormatName(imgType).next();
+        //ImageWriter writer = iter.next();
+        ImageWriteParam iwp = writer.getDefaultWriteParam();
+        iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+        iwp.setCompressionQuality(quality);
+        writer.setOutput(new FileImageOutputStream(outFile));
+        writer.write(null, new IIOImage(thumbImage, null, null),iwp);
+        writer.dispose();
+				/* 14.1.2018 Ende */
+
+
       }
     } catch (InterruptedException ex) {
       System.out.println("Error: " + ex.getLocalizedMessage());

--
Gitblit v1.9.3