I want to convert some images from tif to tif to change the photometric interpretation.
I found the ImageMagick Tool and installed it, in command line the following command works and does what i want:
convert my_image.TIF dest.TIF
Now i want to start it automatically from a Java program.
I'm working on Windows, with Eclipse and ImageMagick 6.8.8.-Q16.
I tried with JMagick, but i only got it working with a previous ImageMagick-Version and this had problems converting tifs (every time i got a black image, also in the command line). The newer ImageMagick-Version was not found by the newest JMagick-Version for Windows.
So i tried to use Java Process Builder or the Runtime exec command, for example:
Process proc = Runtime.getRuntime().exec(new String[]{"convert","my_image.TIF","dest.TIF"});
and
ProcessBuilder pb = new ProcessBuilder("convert", "0011D7FE.TIF", "dest.tif");
pb.redirectErrorStream(true);
try {
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());
} catch(Exception e) { }
No matter, what command i exactly insert, i always get the error message "Invalid Param - dest.tif" for the second param.
I found this article http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=19679 where the problem is similar and the program tries to use some windows convert function.
So I added the ImageMagick-folder to my system variables and also added a new variable which contains this folder to my project build path in eclipse. But I get still the same error.
Is there some other place where I have to set up the path? Or any other explanation for the error I get?