Menu

Converting Images under Windows XP 32bit

Help
r0bb3n
2011-09-01
2013-04-30
  • r0bb3n

    r0bb3n - 2011-09-01

    Hi,

    when I try to crop an image with this code:

            String myPath="C:\\Programs\\ImageMagick-6.3.9-Q16";
            ProcessStarter.setGlobalSearchPath(myPath);
            IMOperation op = new IMOperation();
            op.addImage("c:/tile_small_street.png");
            op.crop(100,50,5,15);
            op.addImage("c:/tile_small_street_out.png");
    
            ConvertCmd cmd = new ConvertCmd();
            cmd.createScript("convert_batch",op);
            cmd.run(op);
    

    I get the following Exception

    19:11:25,467  org.im4java.core.CommandException: java.io.FileNotFoundException: convert 
    org.im4java.core.CommandException: java.io.FileNotFoundException: convert
        at org.im4java.core.ImageCommand.run(ImageCommand.java:215)
    

    The Batch looks like this:

    @echo off
    REM -------------------------------------------------------
    REM  Cmd-script autogenerated by im4java
    REM  at Thu Sep 01 19:11:25 CEST 2011
    REM -------------------------------------------------------
    set PATH=C:\Programs\ImageMagick-6.3.9-Q16;%PATH%
    convert ^
      "c:/tile_small_street.png" ^
      -crop "100x50+5+15" "c:/tile_small_street_out.png"
    

    This batch is running without errors and the image looks correct.

    Also when trying your sample code Test1 I also get errors but they look different:

     1. Testing convert ...
    org.im4java.core.CommandException: org.im4java.core.CommandException: Unzul„ssiger Parameter - "images\tulip
        at org.im4java.core.ImageCommand.run(ImageCommand.java:215)
        at org.im4java.test.TestCase1.run(TestCase1.java:80)
        at org.im4java.test.AbstractTestCase.runTest(AbstractTestCase.java:74)
        at org.im4java.test.TestCase1.main(TestCase1.java:55)
    Caused by: org.im4java.core.CommandException: Unzul„ssiger Parameter - "images\tulip
        at org.im4java.core.ImageCommand.finished(ImageCommand.java:249)
        at org.im4java.process.ProcessStarter.run(ProcessStarter.java:314)
        at org.im4java.core.ImageCommand.run(ImageCommand.java:211)
        ... 3 more
    

    I hope you can help me, because I need it for work.

    Thanks in advance.

    greetz
    r0bb3n

     
  • Bernhard Bablok

    Bernhard Bablok - 2011-09-04

    Hi r0bb3n,

    String myPath="C:\\Programs\\ImageMagick-6.3.9-Q16"; ProcessStarter.setGlobalSearchPath(myPath); /quote]

    im4java will search for convert.exe, convert.cmd and convert.bat in C:\Programs\…. Please verify, that your convert-executable is exactly in the directory which you pass to setGlobalSearchPath.

    The batch-file might work because you probably have the convert-executable somewhere else in your path.

    The test doesn't work because the tests don't set the searchpath internally. To use the tests, you should set IM4JAVA_TOOLPATH. The program fails because it uses a Windows-utility also called convert (but which expects different parameters).

    Bernhard

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.