开发者

image magick problem with java

to be specific in this i'm trying to run the next line on java:

 convert /home/mohamed.hegab/Desktop/1263392123111.jpg -gamma .45455 -resize 400x400 -gamma 2.2 -quality 92 /home/mohamed.hegab/Desktop/small.jpg

which is run great on the bash command line but when i run it on the java using process builder it gives me strange result.

public static void resizeImage(String srcPath, String destPath,String size) {

        ProcessBuilder pb = new ProcessBuilder("convert", srcPath , " -gamma", ".45455",
                " -resize",size, " -gamma ", "2.2", " -quality",
                "92" , destPath);
        pb.redirectErrorStream(true);
        InputStreamReader isr = null;
        BufferedReader br = null;
        try {
            Process p = pb.start();
            p.waitFor();
            isr = new InputStreamReader(p.getInputStream());
            br = new BufferedReader(isr);
            String line = null;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }
        } catch (Exception e) {
            LOG.error("Exception while trying to convert text to image", e);
        } finally {
            try {
                if(isr != null) {
                    isr.close();
                }
  开发者_开发百科              if(br != null) {
                    br.close();
                }
            } catch (IOException e) {
                LOG.error("Could not close stream", e);
            }
        }
    }

the line that comes in the system.out is strange and weird it says that


convert: unable to open image -gamma': No such file or directory @ blob.c/OpenBlob/2439. convert: unable to open image.45455': No such file or directory @ blob.c/OpenBlob/2439. convert: unable to open image -resize': No such file or directory @ blob.c/OpenBlob/2439. convert: unable to open image400x400': No such file or directory @ blob.c/OpenBlob/2439. convert: unable to open image -gamma ': No such file or directory @ blob.c/OpenBlob/2439. convert: unable to open image2.2': No such file or directory @ blob.c/OpenBlob/2439. convert: unable to open image -quality': No such file or directory @ blob.c/OpenBlob/2439. convert: unable to open image92': No such file or directory @ blob.c/OpenBlob/2439.


but the images is comes out only with the size 960 *960 which i don't know where it comes from .

so can any one help me in this :)


Avoid the blanks before the -, shell commands can only recognize options that start with -.


the answer is here in this link

http://www.darcynorman.net/2005/03/15/jai-vs-imagemagick-image-resizing/

simply i should cut the command to pieces in array and run it normally without process builder

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜