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.
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).
精彩评论