bear-zd commited on
Commit
de49ab8
·
1 Parent(s): 8f9daf9

Bug: Fix the bug of file read error

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -5,7 +5,9 @@ from io import BytesIO
5
 
6
  def extract_colors(image, num_colors):
7
  img = BytesIO()
 
8
  img.seek(0)
 
9
  color_thief = ColorThief(img)
10
  palette = color_thief.get_palette(color_count=num_colors)
11
  colors = np.array(palette)
@@ -29,7 +31,6 @@ def process_image(image, num_colors):
29
  palette_str = "palette=" + str(colors.tolist())
30
  hex_colors = colors_to_hex(colors)
31
  hex_palette_str = 'palette=' + str(hex_colors)
32
-
33
  return palette, palette_str, hex_palette_str
34
 
35
  def main():
 
5
 
6
  def extract_colors(image, num_colors):
7
  img = BytesIO()
8
+ image.save(img, format='PNG')
9
  img.seek(0)
10
+
11
  color_thief = ColorThief(img)
12
  palette = color_thief.get_palette(color_count=num_colors)
13
  colors = np.array(palette)
 
31
  palette_str = "palette=" + str(colors.tolist())
32
  hex_colors = colors_to_hex(colors)
33
  hex_palette_str = 'palette=' + str(hex_colors)
 
34
  return palette, palette_str, hex_palette_str
35
 
36
  def main():