imagemagick - Running convert command of image magic using Java gives unable to load module error -
i have written class execute convert command of imagemagic.
public class imagemagicdemo { public static void main(string[] argp){ processbuilder pb2 = new processbuilder("g:\\project\\installation\\imagemagic\\convert","g:\\demo\\image\\frame.jpg", "-resize", "20x20", "g:\\demo\\image\\resizeimage\\frame1.jpg"); pb2.redirecterrorstream(true); process p2; try { p2 = pb2.start(); bufferedreader br = new bufferedreader(new inputstreamreader(p2.getinputstream())); string line = null; while((line=br.readline())!=null){ system.out.println(line); } system.out.println("2"+p2.waitfor()); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } } } but getting following response
convert.exe: unable open image `g:\demo\image\frame.jpg': no such file or directory @ error/blob.c/openblob/2692. convert.exe: unable load module `g:\project\installation\imagemagic\modules\coders\im_mod_rl_jpeg_.dll': specified module not found. @ error/module.c/openmodule/1282. convert.exe: no decode delegate image format `jpg' @ error/constitute.c/readimage/501. convert.exe: no images defined `g:\demo\image\resizeimage\frame1.jpg' @ error/convert.c/convertimagecommand/3212. same problem .png file.i have installed imagemagick-6.9.1-2-q16-x64-dll.exe on window8. if run following command on command prompt
convert -resize 1024x768 g:\\demo\\image\\frame.jpg g:\\demo\\image\\resizeimage\\frame1.jpg it execute , copy resized image in destination folder.if knows please reply.
thanks
i can work, if change working directory executed run, using processbuilder#directory(file)
processbuilder pb = new processbuilder( "c:\\program files\\imagemagick-6.9.1-q16\\convert.exe", "c:\\path\to\large.png", "-resize", "1027x768", "c:\\path\to\small.png"); try { pb.inheritio(); pb.redirecterrorstream(); pb.directory(new file("c:\\program files\\imagemagick-6.9.1-q16")); process p = pb.start(); try (inputstream = p.getinputstream()) { int in = -1; while ((in = is.read()) != -1) { system.out.print((char)in); } } system.out.println("exited " + p.waitfor()); } catch (ioexception | interruptedexception ex) { ex.printstacktrace(); }
Comments
Post a Comment