public BufferedImage convertToColorSpace(final BufferedImage bi, final ColorSpace to) {
        final ColorSpace from = bi.getColorModel().getColorSpace();

        final RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        hints.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        hints.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);

        final ColorConvertOp op = new ColorConvertOp(from, to, hints);

        final BufferedImage result = op.filter(bi, null);

        return relabelColorSpace(result, to);
    }
A selection of tools for evaluating and manipulating color spaces, color values, etc.
<p>
The Javadoc provided in the original code gave the following notation:
</p>
<p>
TODO"This class is a mess and needs to be cleaned up."
</p>
src/main/java/org/apache/commons/imaging/ColorTools.java