In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Php how to modify the color of the picture, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
Php method to modify the color of the picture: 1, to create a PHP example file; 2, through the "img_replace_color ('# 00000000000000mm recording f30145," upload/001.png "," upload/out.png "); method to replace the color in the picture.
This article operating environment: Windows7 system, PHP7.1, Dell G3 computer.
How does php change the color of the picture?
Php replaces the color of the pixels in the picture
Replace one color in the picture with another color
Other colors can also be dealt with, can be removed by themselves and can only replace the positive color.
The background is transparent and the background is white.
/ / replace the colors in the picture / / img_replace_color ('# 000000mlt / f30145, "upload/001.png", "upload/out.png"); / / 255255255127 clear 0000 black and 255heroes 255pr 055pr 055pr 0 [103pr 103pr 03pl 06pr 0 Gray] function img_replace_color ($seachcolor,$replacecolor,$file,$outfile='') {$im=imagecreatefrompng ($file); $newim = imagecreatetruecolor (imagesx ($im), imagesy ($im)); / / create a canvas imagesavealpha ($newim, true) / / background transparent $background = imagecolorallocatealpha ($newim, 255,255,255127); imagefill ($newim,0,0,$background); / / background transparent for ($yellow0% 16) {$r = $c% 16; $c = ($c / 16) > > 0; array_push ($hexAr, $hex [$r]) } array_push ($hexAr, $hex [$c]); $ret = array_reverse ($hexAr); $item = implode ('', $ret); $item = str_pad ($item, 2, '0mm, STR_PAD_LEFT); $hexColor. = $item;} return $hexColor } / * * hexadecimal to RGB * / function hex2rgb ($hexColor) {$color = str_replace ('#','', $hexColor) If (strlen ($color) > 3) {$rgb = array ('r' = > hexdec (substr ($color, 0,2)),'g' = > hexdec (substr ($color, 2,2)),'b' = > hexdec (substr ($color, 4,2) } else {$color = $hexColor; $r = substr ($color, 0,1). Substr ($color, 0,1); $g = substr ($color, 1,1). Substr ($color, 1,1); $b = substr ($color, 2,1). Substr ($color, 2,1); $rgb = array ('r' = > hexdec ($r),'g' = > hexdec ($g),'b' = > hexdec ($b));} return $rgb;}
The answer to the question about how php modifies the color of the picture is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.