private static BufferedImage makeSquare(BufferedImage input){
  if (input.getHeight() == input.getWidth()) {
    return input;
  }
 else {
    int max=Math.max(input.getHeight(),input.getWidth());
    int dx=(max - input.getWidth()) / 2;
    int dy=(max - input.getHeight()) / 2;
    return createImg(max,max,input.getType(),null);
  }
}

private static BufferedImage makeSquare ( BufferedImage input ) { if ( input . getHeight ( ) == input . getWidth ( ) ) { return input ; } else { int max = Math . max ( input . getHeight ( ) , input . getWidth ( ) ) ; int dx = ( max - input . getWidth ( ) ) / 2 ; int dy = ( max - input . getHeight ( ) ) / 2 ; return createImg ( max , max , input . getType ( ) , null ) ; } }
returns an image where the input image is centered .
