Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a rough idea only - you will need to tweak it to your own needs.</p> <p>Basically, I thought that, as colors are recorded as RGB, either as a Hex string "#000000" to "#ffffff", or as an RGB set "rgb(0,0,0)" to "rgb(255,255,255)", and these are interchangeable/translateable, this is a simple mathematical rounding issue.</p> <p>In the full range of colors there would be (16*16)*(16*16)*(16*16) = 256*256*256 = 16,777,216 possible colors.</p> <p>Rounding colors to their closest single character Hex value reduces that to 16*16*16 = 4,096 possible colors. Still far too many, but getting closer.</p> <p>Rounding colors to a single character value, but then limiting that further to being one of 4 (0,3,7,f) reduces it to 4*4*4 = 32. Close enough for me.</p> <p>So, I built a very basic PHP function to try and achieve this:</p> <pre><code>function coloround( $incolor ){ $inR = hexdec( $incolor{0}.$incolor{1} )+1; $inG = hexdec( $incolor{2}.$incolor{3} )+1; $inB = hexdec( $incolor{4}.$incolor{5} )+1; # Round from 256 values to 16 $outR = round( $outR/16 ); $outG = round( $outG/16 ); $outB = round( $outB/16 ); # Round from 16 to 4 $outR = round( $outR/4 ); $outG = round( $outG/4 ); $outB = round( $outB/4 ); # Translate to Hex $outR = dechex( max( 0 , $outR*4-1 ) ); $outG = dechex( max( 0 , $outG*4-1 ) ); $outB = dechex( max( 0 , $outB*4-1 ) ); # Output echo sprintf( '&lt;span style="background-color:#%s;padding:0 10px;"&gt;&lt;/span&gt; &amp;gt; &lt;span style="background-color:#%s;padding:0 10px;"&gt;&lt;/span&gt;%s has been rounded to %s&lt;br&gt;' , $incolor , $outR.$outG.$outB , $incolor , $outR.$outG.$outB ); } </code></pre> <p>This function, when passed a hex string, echos a sample of the original color and a sample of the abbreviated color.</p> <p>This is just a basic proof-of-concept, as I do not know the format Imagemagick is returning the colors as, but you may be able to utilise this logic to create your own.</p> <p>From those 32 colors then, you could group the similar (there would probably be about 8 shades of grey in there) and name the remainder to allow your users to search by them.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload