| | |
| | | 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; |
| | |
| | | |
| | | 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; |
| | | } |
| | | |
| | | /** |