Skip to main content

Merge Tiff Files Input Streams Using Java

SOLVED : Merge Tiff Input Stream list and combine as a single Tiff input stream using java Solution :
public static InputStream mergeTiffFiles(InputStream[] contentElements) throws IOException
   List<BufferedImage> images = new ArrayList<BufferedImage>();
   SeekableStream ss =null;
       return contentElements[0];
     //Iterate over each content element positioned at 0,1,2 in Filenet
     for(InputStream contentElement:contentElements)
       ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", contentElement, null);

       int numPages = decoder.getNumPages();
       //Iterate over each page of the given document and add it to list of buffered images
       for(int j = 0; j < numPages; j++)
         PlanarImage op = new NullOpImage(decoder.decodeAsRenderedImage(j), null, null, OpImage.OP_IO_BOUND);
     //write the merged stream to the file combined.tif in the same folder location
     TIFFEncodeParam params = new TIFFEncodeParam();
     FileOutputStream out = new FileOutputStream("combined.tif");
     ImageEncoder encoder = ImageCodec.createImageEncoder("tiff", out, params);
     List<BufferedImage> imageList = new ArrayList<BufferedImage>(); 
     for (int i = 1; i < images.size(); i++)
     // Read the merged tif file and delete after convert to Input stream
     File mergedFile = new File("combined.tif");    
     ss = new FileSeekableStream(mergedFile);
   catch (Exception e)
     throw new DMFException(Constant.ERROR_WHILE_MERGING_TIFF, e);
   return ss;


Popular posts from this blog

Angular cli ng command is not working

Problem : angular cli command  ng is not working

'ng' is not recognized as an internal or external command,
operable program or batch file.

Solution :

update .npmrc file at C:\Users\{USERNAME}
with the below line


warning: LF will be replaced by CRLF in

Problem :

The file will have its original line endings in your working directory


step1) open .gitconfig file

step2) paste the below code

autocrlf = false
[filter "lfs"]
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process

Download file with extension for internet explorer and chrome using javascript

SOLVED Problem Statement :
Internet explorer download file does not shows file extension

Solution : java script code that append file type extension

function save() { var fileUrl = "${fileUrl}"; var fileName = "${fileName}"; var mimeType = "${mimeType}"; var ie = navigator.userAgent.match(/MSIE\s([\d.]+)/), ie11 = navigator.userAgent .match(/Trident\/7.0/) && navigator.userAgent.match(/rv:11/), ieEDGE = navigator.userAgent .match(/Edge/g), ieVer = (ie ? ie[1] : (ie11 ? 11 : (ieEDGE ? 12 : -1))); if (ie && ieVer < 10) { console.log("No blobs on IE ver<10"); return; } if (ieVer > -1) { console.log(" blobs on IE ver>10"); //,"_self");        var xhr = new XMLHttpRequest();'GET', fileUrl, true); xhr.responseType = 'blob'; xhr.onload = function(e) { if (this.status == 200) { var myBlob = this.response; downloadFileForIE(myBlob, fileName, mimeType); } }; xh…