problem with ImageMagick And Java Runtime Exec

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Emad Hegab

problem with ImageMagick And Java Runtime Exec

Post by Emad Hegab »

Joined: Jan 28, 2010
Messages: 1


[Post New]posted Today 09:34:16 AM private message
Quote [Up]
I Have a bit of a strange problem no java expert i know could solve ..

i need to used imagemagick on my application to make the emails on my website converted to images so no pot can take the emails easily .. the problem solved with image magick command line as following
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 work like magic really and so i tried to put that on the java to run it with Runtime.getRuntime().exec(command) but the result is sadly disappointing .. i have now image as output ..but with no text inside.. i do a sys out to see the command and took the command that outed and put it in the terminal and it worked..so the problem in the Runtime some how.. the code of java is .. in case you are asking


Code: Select all

     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");
    }

it'll give you blank image .. do any one have a solution
Post Reply