Sure, but that's a vague "it would be nice if...". And it would be nice, I agree. But if that's all it is, I doubt it will be implemented any time soon.
You're right. Let me try again.
I suggest that the quantizer returning a number of colors that is different than what the user asked for should be seen as a bug so that it can eventually be fixed by someone.
There are some simple quantizers that can give you exactly what you want, but I doubt you would like the results.
Why not? GraphicsMagick looks like it does it for every supported colorspace and the results are both very fast and also look fine?
The fact is that right now ImageMagick
cannot produce a 37 color YUV quantization for an image I have. Asking for 37 gives 35. Asking for 38 gives 36. Asking for 39 gives 38.
Now you could of course say "But maybe you only need 35?" And my response is "If I needed 35 wouldn't I have asked ImageMagick for 35 instead of 37? Under what circumstances do you think that returning fewer colors than requested is an ideal result if the image can support it?"
GraphicsMagick does it both very quickly and with a pleasing result (maybe because it has two more colors to play with).
Then your question could be "So why not use GraphicsMagick?" And my answer is "Now I am. I figured the ImageMagick developers might like to know that not conforming to the user requested number of colors caused a problem for at least one user."
you can try my script kmeans and specify seed colors for the number of colors you want (assuming that the image has at least that many colors). If you specify just the number of colors, then it will use IM -colors to get the seed colors and you may not get the number you want.
Does your kmeans script run in more time or less time than convert takes? Because convert is already not super fast.
And I should manually preselect K starting colors? I think I'll stick with gm convert for now.