更新色彩
This commit is contained in:
		@@ -138,10 +138,22 @@ func NewSchema(config Config) (graphql.Schema, error) {
 | 
			
		||||
				img, _, err := image.Decode(file)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					fmt.Println("解码图像失败", index, item.ID, item.Content, err)
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				centers, _ := KMeans(extractColors(img), 8)
 | 
			
		||||
				fmt.Println(centers)
 | 
			
		||||
				if err := db.Table("web_images").Where("id = ?", item.ID).Updates(map[string]interface{}{
 | 
			
		||||
					"color_0_r": centers[0].R,
 | 
			
		||||
					"color_0_g": centers[0].G,
 | 
			
		||||
					"color_0_b": centers[0].B,
 | 
			
		||||
					"color_1_r": centers[1].R,
 | 
			
		||||
					"color_1_g": centers[1].G,
 | 
			
		||||
					"color_1_b": centers[1].B,
 | 
			
		||||
				}).Error; err != nil {
 | 
			
		||||
					fmt.Println("更新颜色字段失败", index, item.ID, item.Content, err)
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
				fmt.Println("更新图像颜色索引成功", item.ID, item.Content, centers)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user