private ImageProcessor resize ( ImageProcessor ip , String newWidth ) { if ( newWidth != null ) { try { int width = Integer . parseInt ( newWidth ) ; if ( width < 0 ) { return ip ; } int imgWidth = ip . getWidth ( ) ; int imgHeight = ip . getHeight ( ) ; ip = ip . resize ( width , width * imgHeight / imgWidth ) ; } // no need to do anything with number format exception since the servlet // returns only images; just return the original image catch ( NumberFormatException e ) { } } return ip ; }
Resizes an image to the supplied new width in pixels . The height is reduced proportionally to the new width .