java ProcessBuilder doesn't work right with Imagemagick on windows
I'm using im4java to call imagemagick from a grails app. The command line I'm trying to get it to use is convert "c:\ZonesG\web-app\spresources\summarypage_images\00\09\18\myimage.jpg" -resize 100x100 "c:\ZonesG\web-app\spresources\summarypage_images\00\09\18\myimage_thumbnail100.jpg"
or convert c:\ZonesG\web-app\spresources\summarypage_images\00\09\18\myimage.jpg -resize 100x100 c:\ZonesG\web-app\spresources\summarypage_images\00\09\18\myimage_thumbnail100.jpg
The args passed to ProcessBuilder look correct. There are 5 separate Strings as follows.
convert
c:\Zon开发者_高级运维esG\web-app\spresources\summarypage_images\00\09\18\myimage.jpg
-resize
100x100
c:\ZonesG\web-app\spresources\summarypage_images\00\09\18\myimage_thumbnail100.jpg
I get an error that the -resize parameter is not valid when I run it through processbuilder. That makes it seem as if it is calling the convert function, but something has happened to the parameters so that it no longer recognizes them. It's not the hypens in the directories. I tried it to different directories and it still doesn't work.
When I run it from the command line it works perfectly.
I've tried adding double quotes around the two file names. Again it works great in the command window but doesn't work from the java code.
Any Ideas?
Thanks for your comment Jonathan, Meanwhile, I discovered what was happening.
- The order of the args mattered more when calling from the ProcessBuilder. I changed it so that the resize and geometry are first and the input image file is next. That made it work.
I had this error too. It is actually because it is running a program from Microsoft in Windows called "convert". To get im4java to run the correct you need to make an environment variable. Eg: IM4JAVA_TOOLPATH=C:\Program Files (x86)\ImageMagick-6.6.4-Q16\
精彩评论