code: public static TrimmedTileSet trimTileSet (TileSet source, OutputStream destImage,
                                                String imgFormat)
          throws IOException
      {
          final TrimmedTileSet tset = new TrimmedTileSet();
          tset.setName(source.getName());
          int tcount = source.getTileCount();
          tset._tbounds = new Rectangle[tcount];
          tset._obounds = new Rectangle[tcount];
  
          // grab the dimensions of the original tiles
          for (int ii = 0; ii < tcount; ii++) {
              tset._tbounds[ii] = source.computeTileBounds(ii, new Rectangle());
          }
  
          // create the trimmed tileset image
          TileSetTrimmer.TrimMetricsReceiver tmr = new TileSetTrimmer.TrimMetricsReceiver() {
              public void trimmedTile (int tileIndex, int imageX, int imageY,
                                       int trimX, int trimY, int trimWidth, int trimHeight) {
                  tset._tbounds[tileIndex].x = trimX;
                  tset._tbounds[tileIndex].y = trimY;
                  tset._obounds[tileIndex] = new Rectangle(imageX, imageY, trimWidth, trimHeight);
              }
          };
          TileSetTrimmer.trimTileSet(source, destImage, tmr, imgFormat);
  
          return tset;
      }
docs: Creates a trimmed tileset from the supplied source tileset. The image path must be set by
  hand to the appropriate path based on where the image data that is written to the
  <code>destImage</code> parameter is actually stored on the file system. The image format
  indicateds how the resulting image should be saved.  If null, we save using FastImageIO
  See {@link TileSetTrimmer#trimTileSet} for further information.