WP All Import - 属性项中来自函数编辑器的映射值

问题描述

当我导入我的产品表时,下面的代码函数编辑器中运行。如何将 $result 中的值映射为属性项颜色?

<?PHP
// Start with an image and convert it to a palette-based image
$im = imagecreatefrompng('{shape[1]}.jpg');
imagetruecolortopalette($im,false,255);

// Search colors (RGB)
$colors = array(
    array(254,145,154),array(153,188),90,145),array(255,137,92)
);

// Loop through each search and find the closest color in the palette.
// Return the search number,the search RGB and the converted RGB match
foreach($colors as $id => $rgb)
{
    $result = imagecolorclosest($im,$rgb[0],$rgb[1],$rgb[2]);
    $result = imagecolorsforindex($im,$result);
    $result = "({$result['red']},{$result['green']},{$result['blue']})";

    echo "#$id: Search ($rgb[0],$rgb[2]); Closest match: $result.\n";
}

imagedestroy($im);
?>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)