ImageResizer code improved for scala