Update image_parser.py
Browse files- image_parser.py +19 -19
image_parser.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import os
|
| 3 |
-
from PIL import Image
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
folder = "images"
|
| 7 |
-
|
| 8 |
-
img_list = os.listdir(folder)
|
| 9 |
-
|
| 10 |
-
#looks at the colors in an image and saves the findings to a file
|
| 11 |
-
with open("imageRGBs.txt", 'w') as color_file:
|
| 12 |
-
for image_name in img_list:
|
| 13 |
-
im = Image.open(folder+"
|
| 14 |
-
|
| 15 |
-
#Returns the three main colors of the image
|
| 16 |
-
im2 = im.quantize(colors=3, method=2)
|
| 17 |
-
rgb = im2.getpalette()[:9]
|
| 18 |
-
b = list(map(str, rgb))
|
| 19 |
-
color_file.write(' '.join(b) + ";" + image_name + "\n")
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
folder = "images"
|
| 7 |
+
|
| 8 |
+
img_list = os.listdir(folder)
|
| 9 |
+
|
| 10 |
+
#looks at the colors in an image and saves the findings to a file
|
| 11 |
+
with open("imageRGBs.txt", 'w') as color_file:
|
| 12 |
+
for image_name in img_list:
|
| 13 |
+
im = Image.open(folder+"/"+image_name)
|
| 14 |
+
|
| 15 |
+
#Returns the three main colors of the image
|
| 16 |
+
im2 = im.quantize(colors=3, method=2)
|
| 17 |
+
rgb = im2.getpalette()[:9]
|
| 18 |
+
b = list(map(str, rgb))
|
| 19 |
+
color_file.write(' '.join(b) + ";" + image_name + "\n")
|