Home › Forums › Front-end Issues › Convert HEX value to HSV › Reply To: Convert HEX value to HSV
Unfortunately, your image isn’t working.
The link you supplied was to go from RGB to HSV
I don’t know if you can go direct from HEX to HSV, you may need to convert your HEX to RGB then to HSV – may not be 100% accurate though as going from RGB to HSV.
So you either need to adjust your output setting of the ACF field to the RGBA array (as per my example) OR you need to add the additional step.
<?php
$rgb_hex = get_field('colour');
list($R, $G, $B) = sscanf($rgb_hex, "#%02x%02x%02x");
$hsv = RGBtoHSV($R, $G, $B);
echo '<pre>';
print_r($hsv);
echo '</pre>';
echo '<p>Red: '.$hsv[0].' Green: '.$hsv[1].' Blue: '.$hsv[2].'</p>';
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.