| | |
| | | |
| | | import de.uhilger.filecms.data.FileRef; |
| | | import de.uhilger.filecms.web.Initialiser; |
| | | import de.uhilger.wbx.Bild; |
| | | import java.awt.Container; |
| | | import java.awt.Image; |
| | | import java.awt.MediaTracker; |
| | | import java.awt.Toolkit; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileReader; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.io.Reader; |
| | | import java.security.Principal; |
| | | import java.util.ArrayList; |
| | |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.apache.commons.lang.StringEscapeUtils; |
| | | |
| | | /** |
| | | * |
| | |
| | | } |
| | | return savedFile; |
| | | } |
| | | |
| | | public String bildVerkleinern(String relPath, String bildName) { |
| | | File dir = getTargetDir(relPath); |
| | | File original = new File(dir, bildName); |
| | | Bild bild = new Bild(); |
| | | //for (int i = 0; i < Bild.GR.length; i++) { |
| | | |
| | | //int gr = bild.getVariantenGroesse(i); |
| | | |
| | | String ext = ""; |
| | | String nurname = bildName; |
| | | int dotpos = bildName.indexOf("."); |
| | | if (dotpos > -1) { |
| | | ext = bildName.substring(dotpos); |
| | | nurname = bildName.substring(0, dotpos); |
| | | } |
| | | |
| | | Image image = Toolkit.getDefaultToolkit().getImage(original.getAbsolutePath()); |
| | | MediaTracker mediaTracker = new MediaTracker(new Container()); |
| | | mediaTracker.addImage(image, 0); |
| | | try { |
| | | mediaTracker.waitForID(0); |
| | | |
| | | if(!mediaTracker.isErrorAny()) { |
| | | 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()); |
| | | if(!newImgFile.exists()) { |
| | | logger.fine(original.getAbsolutePath() + " " + newImgFile.getAbsolutePath()); |
| | | bild.writeImageFile(image, bild.getVariantenGroesse(i), bild.getMimeType(original), original.getAbsolutePath(), newImgFile.getAbsolutePath()); |
| | | //bild.writeImageFile(image, photo.getVariantenGroesse(i), photo.getMimetype(), photo.getAbsolutePath(basisPfad), photo.getVariantenName(basisPfad, i)); |
| | | } |
| | | } |
| | | } |
| | | } catch(IOException | InterruptedException ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | } |
| | | |
| | | return "ok"; |
| | | } |
| | | |
| | | /* ---- Hilfsfunktionen ---- */ |
| | | |
| | | private File getTargetDir(String relPath) { |