微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。