ChromeOptions options = new ChromeOptions(); options.addArguments("user-data-dir=/path/to/your/custom/profile");
"Preferences" file will be generated in /path/to/your/custom/profile/Default/ HashMap<String, Object> images = new HashMap<String, Object>();
images.put("images", 2);
HashMap<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values", images);
ChromeOptions chOptions =new ChromeOptions();
chOptions.setExperimentalOption("prefs", prefs);
WebDriver driver = new ChromeDriver(chOptions);
driver.get("http://google.com/images");