code: public static void rotatePage(ImageInputStream imageInput, ImageOutputStream imageOutput, int degree, int pageIndex)
              throws IOException {
          ImageInputStream input = null;
          try {
              List<TIFFPage> pages = getPages(imageInput);
              if (pageIndex != -1) {
                  pages.get(pageIndex).rotate(degree);
              }
              else {
                  for (TIFFPage tiffPage : pages) {
                      tiffPage.rotate(degree);
                  }
              }
              writePages(imageOutput, pages);
          }
          finally {
              if (input != null) {
                  input.close();
              }
          }
      }
docs: Rotates a page of a TIFF file by changing TIFF.TAG_ORIENTATION.
  <p>
  NOTICE: TIFF.TAG_ORIENTATION is an advice how the image is meant do be
  displayed. Other metadata, such as width and height, relate to the image
  as how it is stored. The ImageIO TIFF plugin does not handle orientation.
  Use {@link TIFFUtilities#applyOrientation(BufferedImage, int)} for
  applying TIFF.TAG_ORIENTATION.
  </p>
  
  @param imageInput
  @param imageOutput
  @param degree      Rotation amount, supports 90�, 180� and 270�.
  @param pageIndex   page which should be rotated or -1 for all pages.
  @throws IOException