question: public void ensureMaxSize ( int maxWidth , int maxHeight , boolean keepProportions ) { int width = canvas . getWidth ( ) ; int height = canvas . getHeight ( ) ; if ( keepProportions ) { if ( width > height ) { if ( width > maxWidth ) { height = Math . round ( height *= maxWidth / ( double ) width ) ; width = maxWidth ; } } else { if ( height > maxHeight ) { width = Math . round ( width *= maxHeight / ( double ) height ) ; height = maxHeight ; } } } else { width = Math . min ( width , maxWidth ) ; height = Math . min ( height , maxHeight ) ; } resize ( width , height ) ; }
target:  Ensure a max size for the image