"/usr/local/dhaval/dicom/DicomGenerateThumbnail ", "/usr/local/dhaval/dicom/dicomout.dcm", "/usr/local/dhaval/dicom/dhavaloutput.jpg"
"DicomThumbnailGenerator ", "/tmp/dicomout.dcm", "/tmp/dicomoutput.jpg"
     public InputStream getDestinationStream(InputStream source)            throws Exception     {               InputStream zipp = new BufferedInputStream(source);                  // create a "temp" folder and give its path          OutputStream out = new  FileOutputStream ("/usr/local/dhaval/dicom/dicomout.dcm");            // create a buffer               byte[]  buffer = new byte[1024];              //  Transfer Bytes from input stream to DICOM File          int len;          while ((len = zipp.read(buffer)) >0 )		  {          out.write (buffer,0,len);            }          		  // close OutputStream          out.close();          // system call to the DicomReadWrite executable          String[] cmd = 		  {            "/usr/local/dhaval/dicom/DicomGenerateThumbnail ",            "/usr/local/dhaval/dicom/dicomout.dcm",            "/usr/local/dhaval/dicom/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/dicom/dicomheader.txt");          BufferedWriter writer = new BufferedWriter(new FileWriter(f));                                                                                                                          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 DicomReadWrite 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);          }         File fo = new File("/usr/local/dhaval/dicom/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;        }