Menu

Missing space in script output

Help
Remmelt
2013-02-24
2013-04-30
  • Remmelt

    Remmelt - 2013-02-24

    When using long filenames, the script output misses a space and will therefore not run.

    Example code:

            IMOperation imOperation = new IMOperation();
            imOperation.addImage("/tmp/img1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.jpg");
            imOperation.scale(12);
            imOperation.rotate(34.0);
            imOperation.addImage("/tmp/output.jpg");
            ImageCommand convertCommand = new ConvertCmd();
            try {
                convertCommand.createScript("/tmp/out.sh", imOperation);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
    

    Expected output:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    #!/bin/bash
    #-------------------------------------------------------
    # Bash-script autogenerated by im4java
    # at Sun Feb 24 17:46:46 CET 2013
    #-------------------------------------------------------
    convert \
      \
      "/tmp/img1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.jpg"\
      -scale "12" -rotate "34.0" "/tmp/output.jpg"
    

    Actual output:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    #!/bin/bash
    #-------------------------------------------------------
    # Bash-script autogenerated by im4java
    # at Sun Feb 24 17:46:46 CET 2013
    #-------------------------------------------------------
    convert \
      \
      "/tmp/img1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.jpg"\
      -scale "12"-rotate "34.0" "/tmp/output.jpg"
    

    Note the missing space between "12"-rotate. Running the command, using convertCommand.run(imOperation), does work and produces the correct output image.

     
  • Bernhard Bablok

    Bernhard Bablok - 2013-02-25

    Thanks for the detailed bug-report. I couldn't find anything obvious in the code, I will have to take some time to analyze it.

    Bernhard

     
  • Bernhard Bablok

    Bernhard Bablok - 2013-03-21

    I finally found some time to look at it. The next version will contain a fix. Here's the diff:

    --- src/org/im4java/script/AbstractScriptGenerator.java 11 Jul 2010 10:57:41 -0000      1.7
    +++ src/org/im4java/script/AbstractScriptGenerator.java 19 Mar 2013 18:42:44 -0000      1.8
    @@ -28,7 +28,7 @@
     /**
        This class is an abstract implementation of a ScriptGenerator.
    
    -   @version $Revision: 1.7 $
    +   @version $Revision: 1.8 $
        @author  $Author: bablokb $
      
        @since 1.0.0
    @@ -272,6 +272,7 @@
           iLineBuffer.append(pBuf);
         } else {
           // the given buffer still fits, so append to the line
    +      iLineBuffer.append(" ");
           iLineBuffer.append(pBuf);
           iLineBuffer.append(" ");
         }
    
     

Log in to post a comment.