"gm convert -resize" process...

hffule
2013-03-06
2013-04-30
  • hffule

    hffule - 2013-03-06

    hi,

    I wrote a servlet to resize picture in which I call IM4JAVA to do it.
    My source code  is described as below:

    IMOperation op = new IMOperation();
    op.addImage(path);  // image absolute path
    op.compress("JPEG");
    op.strip();
    op.quality(75.00);
    String size = width + ">";
    op.addRawArgs("-resize", size);   // -resize 800>
    op.addImage("JPEG:-");
    Pipe pipeOut = new Pipe(null, os); // os = response.getOutputStream()
    ConvertCmd convert = new ConvertCmd(true);
    convert.setOutputConsumer(pipeOut);
    convert.run(op);
    return

    when I call the servlet by browser such as IE/Firefox to resize my picture without cancel, it works OK and picture can be shown.
    but when I press "F5" in the browser continually, the picture can not be shown and I found that the process "gm convert -resize" didn't quit
    root     12978  9435  0 16:40 pts/1    00:00:00 gm convert 3f729309.jpg -compress JPEG -strip -quality 75.0 -resize 800> JPEG:-
    root     17220  9435  0 16:45 pts/1    00:00:07 gm convert 7d151f6e.jpg -compress JPEG -strip -quality 75.0 -resize 800> JPEG:-

    there are some exception in my log:
    org.im4java.core.CommandException: ClientAbortException:  java.net.SocketException: Broken pipe
    at org.im4java.core.ImageCommand.run(ImageCommand.java:219) ~

    my question is: how to avoid process zombie when the socket exception occurs in convert command

     
  • Bernhard Bablok

    Bernhard Bablok - 2013-03-07

    Hm, this might be a problem of im4java.  I will have a look at that. Since I will probably have problems reproducing the error, I might ask you to run a test-version - would that be ok for you?

    Bernhard

     
  • hffule

    hffule - 2013-03-07

    thanks for your reply.
    I will run your test-version if you have any fix.
    if you need more info, please contact me
    thanks again.

     
  • Bernhard Bablok

    Bernhard Bablok - 2013-03-21

    I think I found the error. I added the patch below. If you can't patch the source code and compile the library yourself, you could provide me with an email-adress and I'll mail you an updated version of the jar.

    Maybe you could try it out and tell me about the result.

    Thanks, Bernhard

    --- src/org/im4java/process/ProcessStarter.java 11 Jul 2010 10:57:41 -0000      1.38
    +++ src/org/im4java/process/ProcessStarter.java 19 Mar 2013 06:12:00 -0000
    @@ -458,6 +458,7 @@
           Throwable t = e.getCause();
    
           if (t instanceof IOException) {
    +       pProcess.destroy();
             throw (IOException) t;
           } else if(t instanceof RuntimeException) {
             throw (RuntimeException) t;
    
     
  • hffule

    hffule - 2013-03-29

    it is OK now, thanks a lot.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks