From 58f5c30897596a1139c579704ea9f92b62bc9bf9 Mon Sep 17 00:00:00 2001 From: ulrich Date: Sat, 26 Oct 2024 12:32:05 +0000 Subject: [PATCH] fixFileName hinzugefuegt --- src/de/uhilger/neon/image/ImageWorker.java | 61 +++++++++++++++--------------- 1 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/de/uhilger/neon/image/ImageWorker.java b/src/de/uhilger/neon/image/ImageWorker.java index 97bedcb..0f2ef17 100644 --- a/src/de/uhilger/neon/image/ImageWorker.java +++ b/src/de/uhilger/neon/image/ImageWorker.java @@ -42,40 +42,40 @@ /** * Diese String-Konstanten noetigenfalls in eine Konfigurationsdatei auslagern */ - public static final String TN = "_tn"; // 120 - public static final String KL = "_kl"; // 240 - public static final String SM = "_sm"; // 500 - public static final String MT = "_mt"; // 700 - public static final String GR = "_gr"; // 1200 + private final String TN = "_tn"; // 120 + private final String KL = "_kl"; // 240 + private final String SM = "_sm"; // 500 + private final String MT = "_mt"; // 700 + private final String GR = "_gr"; // 1200 - public static final String B64 = "_b64"; // Base64-Encoded + private final String B64 = "_b64"; // Base64-Encoded - public static final String JPG = ".jpg"; - public static final String JPEG = ".jpeg"; - public static final String PNG = ".png"; + //public static final String JPG = ".jpg"; + //public static final String JPEG = ".jpeg"; + //public static final String PNG = ".png"; public void createImages(String baseDir, String fName, String uriStr) throws IOException { - if(uriStr.endsWith(ImageWorker.JPG) || uriStr.endsWith(ImageWorker.JPEG) || uriStr.endsWith(ImageWorker.PNG)) { + //if(uriStr.endsWith(ImageWorker.JPG) || uriStr.endsWith(ImageWorker.JPEG) || uriStr.endsWith(ImageWorker.PNG)) { File dir = new File(baseDir); File imgfile = new File(dir, fName); - ImageWorker actor = new ImageWorker(); - if(uriStr.contains(ImageWorker.TN)) { - actor.createImage(dir, fName, ImageWorker.TN, 120, imgfile); - } else if(uriStr.contains(ImageWorker.KL)) { - actor.createImage(dir, fName, ImageWorker.KL, 240, imgfile); - } else if(uriStr.contains(ImageWorker.SM)) { - actor.createImage(dir, fName, ImageWorker.SM, 500, imgfile); - } else if(uriStr.contains(ImageWorker.MT)) { - actor.createImage(dir, fName, ImageWorker.MT, 700, imgfile); - } else if(uriStr.contains(ImageWorker.GR)) { - actor.createImage(dir, fName, ImageWorker.GR, 1200, imgfile); - } else if(uriStr.contains(ImageWorker.B64)) { + //ImageWorker actor = new ImageWorker(); + if(uriStr.contains(TN)) { + createImage(dir, fName, TN, 120, imgfile); + } else if(uriStr.contains(KL)) { + createImage(dir, fName, KL, 240, imgfile); + } else if(uriStr.contains(SM)) { + createImage(dir, fName, SM, 500, imgfile); + } else if(uriStr.contains(MT)) { + createImage(dir, fName, MT, 700, imgfile); + } else if(uriStr.contains(GR)) { + createImage(dir, fName, GR, 1200, imgfile); + } else if(uriStr.contains(B64)) { File b64File = imgfile; - String fromName = fName.replace(ImageWorker.B64, ""); + String fromName = fName.replace(B64, ""); File fromfile = new File(dir, fromName); - actor.b64Image(fromfile, b64File); + b64Image(fromfile, b64File); } - } + //} } /** @@ -138,11 +138,12 @@ public void setImgSrc(Datei datei, String ext, File b64File) throws IOException { StringBuilder sb = new StringBuilder(); sb.append("data:image/"); - if(ext.equalsIgnoreCase(ImageWorker.JPEG) || ext.equalsIgnoreCase(ImageWorker.JPG)) { - sb.append("jpeg"); - } else if(ext.equalsIgnoreCase(ImageWorker.PNG)) { - sb.append("png"); - } + //if(ext.equalsIgnoreCase(ImageWorker.JPEG) || ext.equalsIgnoreCase(ImageWorker.JPG)) { + // sb.append("jpeg"); + //} else if(ext.equalsIgnoreCase(ImageWorker.PNG)) { + // sb.append("png"); + //} + sb.append(ext.toLowerCase()); sb.append(";base64,"); byte[] buf = new byte[4096]; InputStream is = new FileInputStream(b64File); -- Gitblit v1.9.3