From 91d228bb4af8fde188de7fd2d893ef063a4366e5 Mon Sep 17 00:00:00 2001
From: ulrich <undisclosed>
Date: Mon, 10 Jul 2017 06:50:05 +0000
Subject: [PATCH] TNServlet um zusaetzliche Bildgroessen erweitert

---
 src/de/uhilger/wbx/Bild.java |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/de/uhilger/wbx/Bild.java b/src/de/uhilger/wbx/Bild.java
index 6765204..ab796e9 100644
--- a/src/de/uhilger/wbx/Bild.java
+++ b/src/de/uhilger/wbx/Bild.java
@@ -27,6 +27,7 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.net.FileNameMap;
 import java.net.URLConnection;
 import javax.imageio.ImageIO;
@@ -38,33 +39,40 @@
   
   public static final int WINZIG = 0;
   public static final int KLEIN = 1;
-  public static final int MITTEL = 2;
-  public static final int GROSS = 3;
+  public static final int SEMI = 2;
+  public static final int MITTEL = 3;
+  public static final int GROSS = 4;
   
-  public static final String[] GRNAME = {"-w", "-k", "-m", "-g"};
-  public static final int[] GR = {120, 240, 700, 1200};
+  public static final String[] GRNAME = {"-w", "-k", "-s", "-m", "-g"};
+  public static final int[] GR = {120, 240, 500, 700, 1200};
+  
+  public void writeImageStream(Image image, int gr, String mimeType, OutputStream out) throws InterruptedException, IOException {
+    ImageIO.write(getReducedImage(image, gr, mimeType), imgType(mimeType), out);
+  }
   
   /**
    * 
    * @param image
    * @param gr
    * @param mimeType
-   * @param oName Name der Originaldatei
    * @param vName Name der verkleinerten Datei
    * @throws InterruptedException
    * @throws IOException 
    */
-  public void writeImageFile(Image image, int gr, String mimeType, String oName, String vName) throws InterruptedException, IOException {
+  public void writeImageFile(Image image, int gr, String mimeType, String vName) throws InterruptedException, IOException {
+    ImageIO.write(getReducedImage(image, gr, mimeType), imgType(mimeType), new File(vName));
+  }
+  
+  private BufferedImage getReducedImage(Image image, int gr, String mimeType) throws InterruptedException, IOException {
+    BufferedImage img;
     int q = 90;
     float sh = 0.f;
-    //String mimeType = photo.getMimetype();
-    BufferedImage img;
     if(mimeType.contains("jpeg")) {
       img = getReducedImage(image, gr, gr, q, sh, false);
     } else {
       img = getReducedImage(image, gr, gr, q, sh, true);
     }
-    ImageIO.write(img, imgType(mimeType), new File(vName));
+    return img;
   }
 
   /**

--
Gitblit v1.9.3