I am trying a simple example to crop a image into multiple smaller images. Instead of creating the output files on disk (output file) I want to have it in OutputStream. I have tried few ways of doing the same but not successful. Any help will be benificial. Thanks for helping.

String imPath="C:/Program Files/ImageMagick-7.0.10-Q16-HDRI";
ConvertCmd cmd = new ConvertCmd();
cmd.setSearchPath(imPath);
ByteArrayOutputStream os = new ByteArrayOutputStream();
Pipe pipeOut = new Pipe(null, os);      
ArrayListOutputConsumer arrL = new ArrayListOutputConsumer(); //I tried this also in below but to no avail

cmd.setOutputConsumer(pipeOut);
IMOperation op = new IMOperation();
op.crop(256,256);

op.addImage("D:/matterport-sample-schematic-floor-plan/"+fileName); //Input file
op.addImage("png:-"); //output file
cmd.run(op);

BufferedImage bImage2 = ImageIO.read(new ByteArrayInputStream(os.toByteArray())); 
ImageIO.write(bImage2, "png", new File("D://matterport-sample-schematic-floor-plan/layered.png") ); //This writes only one output image. 

Please note if i don't use Pipe (cmd.setOutputConsumer(pipeOut)) and put op.addImage() all cropped images are created on disk.