Back to project page Photo-Morph.
The source code is released under:
Apache License
If you think the Android project Photo-Morph listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.imageProcess; /*from w w w . j av a 2 s . c om*/ import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import javax.imageio.ImageIO; import javax.jws.WebService; @WebService public class imgProcess { public byte[] getImage(byte []originalArray, int effect) throws InterruptedException{ try{ InputStream in = new ByteArrayInputStream(originalArray); BufferedImage originalbuf = ImageIO.read(in); System.out.println("image about to be saved"); ImageIO.write(originalbuf, "png", new File("F:/images/original.png")); System.out.println("image saved"); processImg(effect); BufferedImage originalImage = ImageIO.read(new File("F:/images/processed.png")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(originalImage, "png", baos); baos.flush(); byte[] imageInByte = baos.toByteArray(); baos.close(); return imageInByte; } catch(IOException e){ System.out.println(e.getMessage()); return null; } } private void processImg(int effect) throws InterruptedException{ String command=""; try{ Process p; switch(effect){ case 1: command = "convert F:/images/original.png -blur 0x4 F:/images/processed.png"; p = Runtime.getRuntime().exec(new String[]{"cmd", "/c",command}); p.waitFor(); break; case 2: command = "convert F:/images/original.png -colorspace Gray F:/images/processed.png"; p = Runtime.getRuntime().exec(new String[]{"cmd", "/c",command}); p.waitFor(); break; case 3: command = "convert F:/images/original.png -negate -edge 5 F:/images/processed.png"; p = Runtime.getRuntime().exec(new String[]{"cmd", "/c",command}); p.waitFor(); break; case 4: command = "convert F:/images/original.png -negate F:/images/processed.png"; p = Runtime.getRuntime().exec(new String[]{"cmd", "/c",command}); p.waitFor(); break; case 5: command = "convert F:/images/original.png -sepia-tone 90% F:/images/processed.png"; p = Runtime.getRuntime().exec(new String[]{"cmd", "/c",command}); p.waitFor(); break; case 6: command = "convert F:/images/original.png -blur 0x8 -emboss 5 F:/images/processed.png"; p = Runtime.getRuntime().exec(new String[]{"cmd", "/c",command}); p.waitFor(); break; } }catch(IOException e){ System.out.println(e.getMessage()); } } }