question: public static void createTmpThumb ( final InputStream stream , final File file , final String fileName , final IConfiguration conf ) throws IOException { BufferedInputStream bufferedIS = new BufferedInputStream ( stream ) ; bufferedIS . mark ( Integer . MAX_VALUE ) ; BufferedImage image = ImageIO . read ( bufferedIS ) ; if ( image == null ) { throw new IOException ( "Wrong file" ) ; } Dimension dimension = createThumbDimension ( image , conf . getImgWidth ( ) , conf . getImgHeight ( ) ) ; if ( image . getHeight ( ) == dimension . height && image . getWidth ( ) == dimension . width ) { bufferedIS . reset ( ) ; writeUntouchedImage ( bufferedIS , file ) ; } else { resizeImage ( image , dimension . width , dimension . height , conf . getImgQuality ( ) , file ) ; } stream . close ( ) ; }
target:  Uploads image and if the image size is larger than maximum allowed it resizes the image.