Treat bad values passed to --images as a fatal error

If an option is passed to --images that is either a non-existent path or
a folder with no images matching the supported types, assume this is
an error and exit, so they can supply a valid path instead.

Share code between DM and nanobench in SkCommonFlags.

nanobench now behaves more like DM - it will check a directory for
images that match the supported extensions.

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1611323004

Review URL: https://codereview.chromium.org/1611323004
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 7b37562..31efefa 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -586,19 +586,8 @@
         fUseMPDs.push_back() = false;
 
         // Prepare the images for decoding
-        for (int i = 0; i < FLAGS_images.count(); i++) {
-            const char* flag = FLAGS_images[i];
-            if (sk_isdir(flag)) {
-                // If the value passed in is a directory, add all the images
-                SkOSFile::Iter it(flag);
-                SkString file;
-                while (it.next(&file)) {
-                    fImages.push_back() = SkOSPath::Join(flag, file.c_str());
-                }
-            } else if (sk_exists(flag)) {
-                // Also add the value if it is a single image
-                fImages.push_back() = flag;
-            }
+        if (!CollectImages(&fImages)) {
+            exit(1);
         }
 
         // Choose the candidate color types for image decoding