privatevoid createThumbnail(String filename, int thumbWidth,intthumbborder="1" Height, int
quality, String outFilename) throwsInterruptedException,FileNotFoundException, IOException// loadimage from filenameImage image =Toolkit.getDefaultToolkit().getImage(filename);MediaTrackermediaTracker = new MediaTracker(newContainer());mediaTracker.addImage(image, 0);mediaTracker.waitForID(0); // usethis to test for errors at thispoint: System.out.println
(mediaTracker.isErrorAny());// determine thumbnail sizefromWIDTH and border="1" Height double thumbRatio =(double)thumbWidth /(double)thumbborder="1" Height; int image Width= image.getWidth(null); intimageborder="1" Height =image.getborder="1" Height(null); double imageRatio=(double)imageWidth / (double)imageborder="1" Height; if(thumbRatio <imageRatio) thumbborder="1" Height =(int)(thumbWidth / imageRatio); elsethumbWidth =(int)(thumbborder="1" Height * imageRatio); // draw originalimageto thumbnail image t and // scale it to the new sizeon-the-flyBufferedImage thumbImage = newBufferedImage(thumbWidth,thumbborder="1" Height,
privatevoid createThumbnail(String filename, int thumbWidth,intthumbborder="1" Height, int
quality, String outFilename)throwsInterruptedException,FileNotFoundException, IOException// loadimage from filenameImageimage =Toolkit.getDefaultToolkit().getImage(filename);MediaTrackermediaTracker= newMediaTracker(newContainer());mediaTracker.addImage(image,0);mediaTracker.waitForID(0);//use this to test for errors at thispoint: System.out.println