$pattern = "/#(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b/";
if(preg_match_all($pattern, $file, $matches, PREG_PATTERN_ORDER));
$data["colors"] = $matches[0];
So basically what i need to do is manipulate a SVG image so that we can count the number of colors and change the colors of that image using php. From the above code i can find what colors are being used but the problem is that i have to match the colors in another array of colors where if the hex code isn't matched then i have to select the closest match to that color. I have to be able to then save that information to the SVG file.
This is my Color Array:
$pantone = [
[
"Pantone" => "Yellow",
"Hex" => "FEDD00",
"R" => "254",
"G" => "221",
"B" => "0"
],
[
"Pantone" => "Yellow 012",
"Hex" => "FFD700",
"R" => "255",
"G" => "215",
"B" => "0"
],
[
"Pantone" => "Orange 021",
"Hex" => "FE5000",
"R" => "254",
"G" => "80",
"B" => "0"
],
[
"Pantone" => "Warm Red",
"Hex" => "F9423A",
"R" => "249",
"G" => "66",
"B" => "58"
],
[
"Pantone" => "Red 032",
"Hex" => "EF3340",
"R" => "239",
"G" => "51",
"B" => "64"
],
[
"Pantone" => "Rubine Red",
"Hex" => "CE0058",
"R" => "206",
"G" => "0",
"B" => "88"
],
[
"Pantone" => "Rhodamine Red",
"Hex" => "E10098",
"R" => "225",
"G" => "0",
"B" => "152"
],
];
This is link to my SVG with Regex
Please do inform me if i am incomplete in my question.