开发者

change shirt color with gd library

开发者 https://www.devze.com 2023-04-06 08:39 出处:网络
i m trying to change color of a shirt. here i开发者_如何学Pythons my code in its simplest form.

i m trying to change color of a shirt. here i开发者_如何学Pythons 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.

change shirt color with gd library

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


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消