I'm currently building a java application using im4java, ImageMagick and Ghostscript.
At this point everything works nice and smooth except for one thing.
I'm asking im4java to make thumbnails out of PDFs.
While most of the PDFs are well processed, some others are not well handled : Broken and not well understood by Ghostscript ( on purpose ) PDFs.
I've got an error message displaying in the Console but then im4java does nothing. The convert.exe process attached to the java process shows no sign of activity, CPU or memory.
The operation is hanging, doing nothing and showing no exception.
Dealing with corrupted or malformed pdf is of course part of my application but i can't figure how to stop the im4java operation and throw an exception to deal with this Ghostscript problem.
Any idea ?
Thanks a lot for reading ( and maybe answering ;) )
Hi, this is a rather strange behavior. Do you have the same problem (hanging convert.exe) if you run it from the command-line? Changing the ErrorConsumer should not make any difference, since the default ErrorConsumer just reads stderr into an array and throws an exception after termination of the process.
Bernhard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello all,
I'm currently building a java application using im4java, ImageMagick and Ghostscript.
At this point everything works nice and smooth except for one thing.
I'm asking im4java to make thumbnails out of PDFs.
While most of the PDFs are well processed, some others are not well handled : Broken and not well understood by Ghostscript ( on purpose ) PDFs.
I've got an error message displaying in the Console but then im4java does nothing. The convert.exe process attached to the java process shows no sign of activity, CPU or memory.
The operation is hanging, doing nothing and showing no exception.
Dealing with corrupted or malformed pdf is of course part of my application but i can't figure how to stop the im4java operation and throw an exception to deal with this Ghostscript problem.
Any idea ?
Thanks a lot for reading ( and maybe answering ;) )
*Maxime*
_________________
im4java Operation code snippet :
try {
IMOperation op = new IMOperation();
op.addImage(new String { sourceFilePath + (page != -1 ? ("") : "") });
op.thumbnail(new Integer(width), new Integer(height));
op.strip();
op.quality(60d);
op.samplingFactor(2d, 1d);
op.addImage(new String { destinationFilePath });
this.convertCommand.run(op);
} catch (CommandException ce) {
throw new PluginException(ce.getErrorText().toString(), ce.getClass().getName(), ce.getMessage(), ce.getCause());
} catch (Exception e) {
throw new PluginException(e.getClass().getName(), e.getMessage(), e.getCause());
}
Ghostscript Error Message :
*Error: /undefined in -run-
Operand stack:
-dict:1/1(L)- Root
Execution stack:
%interp_exit .runexec2 -nostringval- -nostringval- -nostringval- 2 %stopped_push -nostringval- -nostringval- -nostringval- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1 3 %oparray_pop -nostringval- -nostringval- -nostringval- -nostringval- -nostringval- -nostringval-
Dictionary stack:
-dict:1156/1684(ro)(G)- -dict:1/20(G)- -dict:74/200(L)- -dict:74/200(L)- -dict:106/127(ro)(G)- -dict:278/300(ro)(G)- -dict:20/25(L)-
Current allocation mode is local*
Got my answer :
ImageCommand.setErrorConsumer()
Hi, this is a rather strange behavior. Do you have the same problem (hanging convert.exe) if you run it from the command-line? Changing the ErrorConsumer should not make any difference, since the default ErrorConsumer just reads stderr into an array and throws an exception after termination of the process.
Bernhard