Buggy code:
@ Controller public class AbstractBinaryController { private static final Logger LOG = LoggerFactory . getLogger ( AbstractBinaryController . class ) ; private static final String DATE_FORMAT = "EEE,<seq2seq4repair_space>dd<seq2seq4repair_space>MMM<seq2seq4repair_space>yyyy<seq2seq4repair_space>HH:mm:ss<seq2seq4repair_space>zzz" ; private static final TimeZone GMT = TimeZone . getTimeZone ( "GMT" ) ; private static final String IF_MODIFIED_SINCE = "If-Modified-Since" ; private static final String LAST_MODIFIED = "Last-Modified" ; private static final String CONTENT_LENGTH = "Content-Length" ; @ Resource private PublicationResolver publicationResolver ; @ Resource private BinaryFactory binaryFactory ; private String binaryRootFolder ; private boolean useBinaryStorage = true ; private boolean removeContextPath = false ; public void getBinary ( final HttpServletRequest request , final HttpServletResponse response ) throws ItemNotFoundException { } private String insertIntoPath ( String path , String toInsert ) { } private String getImageType ( String path ) { } private void fillResponse ( final HttpServletRequest request , final HttpServletResponse response , final Binary binary , final String path , int resizeToWidth ) throws IOException { InputStream content = null ; try { final long contentLength ; if ( isUseBinaryStorage ( ) ) { File binaryFile = new File ( path ) ; if ( ( ! ( binaryFile . exists ( ) ) ) || ( binary . getLastPublishedDate ( ) . isAfter ( binaryFile . lastModified ( ) ) ) ) { if ( resizeToWidth == ( - 1 ) ) { saveBinary ( binary , binaryFile ) ; } else { File tempBinary = new File ( ( path + ".tmp" ) ) ; saveBinary ( binary , tempBinary ) ; content = new FileInputStream ( tempBinary ) ; BufferedImage before = ImageIO . read ( content ) ; int w = before . getWidth ( ) ; int h = before . getHeight ( ) ; float factor = ( ( float ) ( resizeToWidth ) ) // w ; int newH = Math . round ( ( factor * h ) ) ; <START_BUG> BufferedImage after = new BufferedImage ( resizeToWidth , newH , BufferedImage . TYPE_INT_RGB ) ; <END_BUG> Graphics g = after . createGraphics ( ) ; g . drawImage ( before , 0 , 0 , resizeToWidth , newH , null ) ; g . dispose ( ) ; ImageIO . write ( after , getImageType ( path ) , binaryFile ) ; } } content = new FileInputStream ( binaryFile ) ; contentLength = binaryFile . length ( ) ; } else { content = binary . getBinaryData ( ) . getInputStream ( ) ; contentLength = binary . getBinaryData ( ) . getDataSize ( ) ; } response . setContentType ( getContentType ( binary , path , request ) ) ; response . setHeader ( AbstractBinaryController . CONTENT_LENGTH , Long . toString ( contentLength ) ) ; response . setHeader ( AbstractBinaryController . LAST_MODIFIED , createDateFormat ( ) . format ( binary . getLastPublishedDate ( ) . toDate ( ) ) ) ; response . setStatus ( OK . value ( ) ) ; byte [ ] buffer = new byte [ response . getBufferSize ( ) ] ; int len ; while ( ( len = content . read ( buffer ) ) != ( - 1 ) ) { response . getOutputStream ( ) . write ( buffer , 0 , len ) ; } } finally { if ( content != null ) { try { content . close ( ) ; } catch ( IOException e ) { AbstractBinaryController . LOG . error ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>close<seq2seq4repair_space>binary<seq2seq4repair_space>input<seq2seq4repair_space>stream" , e ) ; } } } } private String getContentType ( final Binary binary , final String path , final HttpServletRequest request ) { } protected String getBinaryPath ( final HttpServletRequest request ) { } private void saveBinary ( final Binary binary , final File binaryFile ) throws IOException { } public void setBinaryRootFolder ( final String binaryRootFolder ) { } public boolean isUseBinaryStorage ( ) { } public void setUseBinaryStorage ( final boolean useBinaryStorage ) { } public boolean isRemoveContextPath ( ) { } public void setRemoveContextPath ( final boolean removeContextPath ) { } void clearBinaryStorage ( ) throws IOException { } private DateFormat createDateFormat ( ) { } }

Fix:
BufferedImage after = new BufferedImage ( resizeToWidth , newH , BufferedImage . TYPE_INT_ARGB ) ;