| | |
| | | |
| | | package de.uhilger.filecms.api; |
| | | |
| | | import de.uhilger.filecms.data.Bild; |
| | | import de.uhilger.filecms.data.FileRef; |
| | | import de.uhilger.filecms.pub.AbstractComparator; |
| | | import de.uhilger.filecms.pub.FileNameComparator; |
| | | import java.awt.Container; |
| | | import java.awt.Image; |
| | | import java.awt.MediaTracker; |
| | | import java.awt.Toolkit; |
| | | import de.uhilger.wbx.Bild; |
| | | import java.io.File; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | |
| | | import java.util.logging.Logger; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipFile; |
| | | import net.coobird.thumbnailator.Thumbnails; |
| | | import org.apache.commons.io.FileUtils; |
| | | |
| | | /** |
| | |
| | | nurname = bildName.substring(0, dotpos); |
| | | } |
| | | |
| | | // 120, 240, 500, 700, 1200 |
| | | |
| | | |
| | | for (int i = 0; i < Bild.GR.length; i++) { |
| | | StringBuffer buf = new StringBuffer(); |
| | | buf.append(nurname); |
| | | buf.append(bild.getVariantenName(i)); |
| | | buf.append(ext); |
| | | File newImgFile = new File(dir, buf.toString()); |
| | | try { |
| | | Thumbnails.of(original) |
| | | .size(bild.getVariantenGroesse(i), bild.getVariantenGroesse(i)) |
| | | .keepAspectRatio(true) |
| | | .toFile(newImgFile); |
| | | } catch (IOException ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | } |
| | | } |
| | | /* |
| | | Image image = Toolkit.getDefaultToolkit().getImage(original.getAbsolutePath()); |
| | | MediaTracker mediaTracker = new MediaTracker(new Container()); |
| | | mediaTracker.addImage(image, 0); |
| | |
| | | } catch (IOException | InterruptedException ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | } |
| | | */ |
| | | return "ok"; |
| | | } else { |
| | | return "Pfad micht erlaubt."; |
| | | } |
| | | } |
| | | |
| | | public String bildRotieren(String relPath, String bildName) { |
| | | if (!relPath.startsWith(".")) { |
| | | File dir = getTargetDir(relPath); |
| | | File original = new File(dir, bildName); |
| | | |
| | | String ext = ""; |
| | | String nurname = bildName; |
| | | int dotpos = bildName.indexOf("."); |
| | | if (dotpos > -1) { |
| | | ext = bildName.substring(dotpos); |
| | | nurname = bildName.substring(0, dotpos); |
| | | } |
| | | |
| | | StringBuffer buf = new StringBuffer(); |
| | | buf.append(nurname); |
| | | buf.append("-rot"); |
| | | buf.append(ext); |
| | | File newImgFile = new File(dir, buf.toString()); |
| | | |
| | | logger.fine("original: " + original.getAbsolutePath() + " newImgFile: " + newImgFile.getAbsolutePath()); |
| | | |
| | | try { |
| | | Thumbnails.of(original) |
| | | .scale(1) |
| | | .rotate(90) |
| | | .toFile(newImgFile); |
| | | } catch (IOException ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | } |
| | | |
| | | |
| | | return "ok"; |
| | | } else { |
| | | return "Pfad micht erlaubt."; |
| | | } |
| | | } |
| | | public String extractZipfile(String relPath, String filename) { |
| | | String result = null; |
| | | if (!relPath.startsWith(".")) { |