Problem with ImageMagick and Java Runtime Exec

I have a slightly strange problem, I don't know the java expert I know.

I need to use imagemagick in my application to make emails on my website converted to images, so no bank can send emails easily. The problem is solved using the command line with the image. <b> convert -size 200x30 xc: transparent -font / home / emad / TITUSCBZ.TTF -fill black -pointsize 12 -draw "text 5.15 ' emadhegab@hotmail.com '" /home/emad/test.png

and it works like magic, and so I tried putting this on java to run it with Runtime.getRuntime (). Exec (command) but the result is sadly disappointing. I now have an image as a result .. but without text inside. I do sys out to see the command, and took the command that came out and put it in the terminal, and it worked ... the problem in Runtime is some kind of .. java code is .. in case you ask

==================

            String size = ("1000x1030");

    String path = System.getProperty("user.home");
    String command="convert -size "+ size +" xc:white -font /tmp/TITUSCBZ.TTF -pointsize 12 -draw 'text 300,300 \"emadhegab@hotmail.com\"' "+path +"/test.jpg";
    try{
    Process proc =Runtime.getRuntime().exec(command);

    System.out.println(command);
    }catch(Exception e){
        System.out.println("error");
    }

===================

he will give you a blank image .. anyone has a solution

0
source share
4 answers

This works for me:

String size = "1024x768";
ProcessBuilder pb = new ProcessBuilder("convert", "-size", size,
        "xc:white", "-font",
        "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf",
        "-pointsize", "12", "-draw",
        "text 300,300 \"*****@hotmail.com\"",
        "/home/djo/Pictures/rainy.jpeg");
pb.redirectErrorStream(true);

Process p = pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = null;
while((line=br.readLine())!=null){
    System.out.println(line);
}
System.out.println(p.waitFor());

Note that I removed single quotes from the draw part.

0
source

, args String, .

String[] cmd = {"convert",  "-size", "size", "c:white", ..., path +"/test.jpg"};
+2

Java- -?

, , , user.home .

, (300, 300) (/tmp/TITUSCBZ.TTF) , . , .

0

:

0
source

All Articles