with im4java using SequenceInputStream, PipedInputStream and PipedOutputStream. The problem is that after reading the output of the first convert process within the loop, SequenceInputStream receives a "Pipe broken" IOException from PipedInputStream, as the stream was not closed by Pipe in provideInput().
A simple iSource/Sink.close(); after each copyBytes solves the problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm not quite sure if this is the correct solution. I have been working on this issue recently, and temporarily thought about adding an explicit close()-method to Pipe, but discarded the idea because all my test-programs work fine without it. But maybe my programs don't cover all relevant issues, so you might want to post your code and I will further investigate the issue.
The main argument against closing the stream within Pipe is that the streams are created outside and passed to Pipe in the constructor. In a way they are foreign objects and the creator should be responsible of changing them.
Bernhard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The Pipe class is buggy, as it does not close the streams after processing input/output/error. This is important for replicating functionality like:
offset=0; for image in .jpg; do
convert $image -resize 100x100 +polaroid -repage +$offset+0\! MIFF:-;
(( offset = $offset + 100 ));
done |
convert MIFF:- -layers merge +repage out.png && xdg-open out.png
with im4java using SequenceInputStream, PipedInputStream and PipedOutputStream. The problem is that after reading the output of the first convert process within the loop, SequenceInputStream receives a "Pipe broken" IOException from PipedInputStream, as the stream was not closed by Pipe in provideInput().
A simple iSource/Sink.close(); after each copyBytes solves the problem.
I'm not quite sure if this is the correct solution. I have been working on this issue recently, and temporarily thought about adding an explicit close()-method to Pipe, but discarded the idea because all my test-programs work fine without it. But maybe my programs don't cover all relevant issues, so you might want to post your code and I will further investigate the issue.
The main argument against closing the stream within Pipe is that the streams are created outside and passed to Pipe in the constructor. In a way they are foreign objects and the creator should be responsible of changing them.
Bernhard