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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
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
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.
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
it is OK now, thanks a lot.