Automatically crop borders from images