duanmao9918 2011-09-19 11:26
浏览 27

用gd库改变衬衫颜色

i m trying to change color of a shirt. here is my code in its simplest form.

$imgname = "me.jpg";
$im = imagecreatefromjpeg ($imgname);
imagetruecolortopalette($im,false, 255);

$index = imagecolorclosest ( $im, 96, 132, 194 ); // get COlor
imagecolorset($im,$index,92,92,92); // SET NEW COLOR

$imgname = "result.jpg";
imagejpeg($im, $imgname ); // save image as gif
//imagedestroy($im);

but this code does change only specific color. You can see in attached image. enter image description here

i want whole shirt color changed from blue to grey. is it possible with GD library or any other library? If yes how??

  • 写回答

1条回答 默认 最新

  • duanjian4150 2011-09-20 17:26
    关注

    Using GD to accomplish this seems like using chainsaw to slice bread. An easier (and I think better) way to handle this would be to have the shirt be a transparent PNG with transparent shadows in the correct places. Then you can simply change the background color of the image container using any number of freely available color pickers. Since the shirt is transparent, it then becomes the color of the background (blue, gray, whatever). Once the user has selected a color that works, you can pass that hex color to the back-end along with the rest of the order information (size, etc).

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么