private boolean resizeAndSaveImage ( int maxWidth , int maxHeight ) throws IOException { // Decode image file, compress and re-save it boolean saved = false ; File targetFile = configuration . diskCache . get ( uri ) ; if ( targetFile != null && targetFile . exists ( ) ) { ImageSize targetImageSize = new ImageSize ( maxWidth , maxHeight ) ; DisplayImageOptions specialOptions = new DisplayImageOptions . Builder ( ) . cloneFrom ( options ) . imageScaleType ( ImageScaleType . IN_SAMPLE_INT ) . build ( ) ; ImageDecodingInfo decodingInfo = new ImageDecodingInfo ( memoryCacheKey , Scheme . FILE . wrap ( targetFile . getAbsolutePath ( ) ) , uri , targetImageSize , ViewScaleType . FIT_INSIDE , getDownloader ( ) , specialOptions ) ; Bitmap bmp = decoder . decode ( decodingInfo ) ; if ( bmp != null && configuration . processorForDiskCache != null ) { L . d ( LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK , memoryCacheKey ) ; bmp = configuration . processorForDiskCache . process ( bmp ) ; if ( bmp == null ) { L . e ( ERROR_PROCESSOR_FOR_DISK_CACHE_NULL , memoryCacheKey ) ; } } if ( bmp != null ) { saved = configuration . diskCache . save ( uri , bmp ) ; bmp . recycle ( ) ; } } return saved ; }
Decodes image file into Bitmap resize it and save it back