Esempio n. 1
0
 if taobao_sizes:
     first_size_key = taobao.get_taobao_frist_size_key(taobao_sizes)
 current_dir = taobao.get_current_dir()
 add_color_remove = []
 for color, key in add_color.items():
     str_key = re.sub("[:]", "", key)
     image_name = str(taobao_id) + "_" + str_key + ".jpg"
     image_path = current_dir + "\img\\" + image_name
     if taobao_sizes:
         image_key = first_size_key + ";" + key
     else:
         image_key = key
     print(image_key)
     if image_key in taobao_products:
         print(taobao_products[image_key][5])
         taobao.download_taobao_image(taobao_products[image_key][5],
                                      image_path)
     else:
         add_color_remove.append(color)
         continue
     im = Image.open(image_path)
     rgb_im = im.convert('RGB')
     (x, y) = rgb_im.size
     if (x < 800 or y < 800):
         if (x < y):
             x_s = 1000
             y_s = y * x_s / x
             out = rgb_im.resize((x_s, int(y_s)), Image.ANTIALIAS)
             out.save(image_path)
         else:
             y_s = 1000
             x_s = x * y_s / y