"/usr/local/dhaval/metaimage/GenerateThumbnail", "/usr/local/dhaval/metaimage/" + entryName, "/usr/local/dhaval/metaimage/dhavaloutput.jpg"
"ITKThumbnailGenerator", "/tmp/" + entryName, "/tmp/gzipoutput.jpg"
     public InputStream getDestinationStream(InputStream source)            throws Exception     {             TarInputStream tin = new TarInputStream(new GZIPInputStream( source ));        //get the first entry in the archive        TarEntry tarentry = tin.getNextEntry();        String entryName = tarentry.getName();           // create a "temp" folder and give its path        String filename = "/usr/local/dhaval/metaimage/";        while (tarentry != null)		{        OutputStream out = new  FileOutputStream(new File (filename + tarentry.getName()));         tin.copyEntryContents(out);         tarentry = tin.getNextEntry();          }          if (tin == null) 		{        if (MediaFilterManager.isVerbose)           {             System.out.println (" Zip file 'zipp' is null ");           }        };          if (MediaFilterManager.isVerbose)        {            System.out.println (" The File Selected for Generating Thumbnail is " );            System.out.println ("" +  entryName);            System.out.println ("  ");        }         // system call to the ITKReadWrite executable        String[] cmd = 		{          "/usr/local/dhaval/metaimage/GenerateThumbnail",          "/usr/local/dhaval/metaimage/" + entryName,          "/usr/local/dhaval/metaimage/dhavaloutput.jpg"        };                                                                                                                                     Process p =  Runtime.getRuntime().exec(cmd);                                                                                                                                     // put a BufferedReader on the output                                                                                                                                    InputStream inputstream = p.getInputStream();       InputStreamReader inputstreamreader = new InputStreamReader(inputstream);       BufferedReader bufferedreader = new BufferedReader(inputstreamreader);                                                                                                                                    // read the output           //   File f = new File("/usr/local/dhaval/metaimage/dicomheader.txt");       //   BufferedWriter writer = new BufferedWriter(new FileWriter(f));             //   writer.write(" The Header Contents of the File "+ entryName + " Selected for Generating Thumbnail is ");       //   writer.newLine();                                                                                                                         //   String line;       //   while ((line = bufferedreader.readLine()) != null) {       //           if (MediaFilterManager.isVerbose)       //          {       //              System.out.println(line);       //           }       //           writer.write(line);       //           writer.newLine(); //write system dependent end of line       //      }                                     //   writer.close(); //close to unlock and flush to disk                                                                                                                                    // check for ITKReadWrite failure                                                                                                                                    try 	   {              if (p.waitFor() != 0) 			  {                  if (MediaFilterManager.isVerbose)                  System.err.println("exit value = " + p.exitValue());               }       }       catch (InterruptedException e) 	   {              if (MediaFilterManager.isVerbose)                System.err.println(e);       }       tin.close();       File fo = new File("/usr/local/dhaval/metaimage/dhavaloutput.jpg");       BufferedImage buf = ImageIO.read(fo);       buf.flush();               // get config params       float xmax = (float) ConfigurationManager.getIntProperty("thumbnail.maxwidth");       float ymax = (float) ConfigurationManager.getIntProperty("thumbnail.maxheight");       Image thumb = null;       // now get the image dimensions       float xsize = (float) buf.getWidth(null);       float ysize = (float) buf.getHeight(null);       // if verbose flag is set, print out dimensions       // to STDOUT       if (MediaFilterManager.isVerbose)       {            System.out.println("original size: " + xsize + "," + ysize);       }       // scale by x first if needed       if (xsize > xmax)       {            // calculate scaling factor so that xsize * scale = new size (max)            float scale_factor = xmax / xsize;            // if verbose flag is set, print out extracted text            // to STDOUT            if (MediaFilterManager.isVerbose)            {                System.out.println("x scale factor: " + scale_factor);            }            // now reduce x size            // and y size            xsize = xsize * scale_factor;            ysize = ysize * scale_factor;            // if verbose flag is set, print out extracted text            // to STDOUT            if (MediaFilterManager.isVerbose)           {                System.out.println("new size: " + xsize + "," + ysize);           }       }        // scale by y if needed       if (ysize > ymax)       {            float scale_factor = ymax / ysize;            // now reduce x size            // and y size            xsize = xsize * scale_factor;            ysize = ysize * scale_factor;        }        // if verbose flag is set, print details to STDOUT        if (MediaFilterManager.isVerbose)        {            System.out.println("thumbnail size: " + xsize + ", " + ysize);        }               thumb = buf.getScaledInstance((int) xsize, (int) ysize,Image.SCALE_SMOOTH);        // create a BufferedImage to draw this image into...        BufferedImage thumbnail = new BufferedImage(thumb.getWidth(null), thumb.getHeight(null),   BufferedImage.TYPE_BYTE_GRAY);        Graphics2D g2d = thumbnail.createGraphics();        // draw thumb into thumbnail        g2d.drawImage(thumb, null, null);                       	          // now create an input stream and return it               ByteArrayOutputStream baos = new ByteArrayOutputStream();                                                                                                                                       ImageIO.write(buf,"jpeg",baos);         // now get the array        ByteArrayInputStream bais = new ByteArrayInputStream ( baos.toByteArray());                                                                                            return bais;     }