Class ColorSpaceConverter

Namespace
SoftZenPdf.Optimizer
Assembly
SoftZenPdf.Optimizer.dll

Converts CMYK images to RGB, which takes three samples per pixel instead of four and lets JPEGs use YCbCr with subsampled colour. Colours are converted with a device formula (see Formula), after the image's /Decode array, without colour management, so they can shift from how a colour-managed viewer shows CMYK. JPEGs are saved again as JPEG at their original quality, other images losslessly, and palette images only have their palette converted. Run it before an ImageQualityOptimizer so the converted images are compressed too.

public sealed class ColorSpaceConverter : OptimizationHandler
Inheritance
ColorSpaceConverter
Inherited Members

Examples

optimizer.AddOptimizationHandler(new ColorSpaceConverter());
optimizer.AddOptimizationHandler(new ImageQualityOptimizer { JpegProcessor = new JpegCompressor(0.75f) });

Remarks

Documents with a CMYK output intent (PDF/A or PDF/X for print) are left alone, since converting would break their conformance. Images with a colour-key mask, whose exact CMYK values have a meaning, and images sharing a soft mask that has a /Matte colour with another image are skipped. Colours in page content (such as text drawn in CMYK) are not changed.

Properties

ConvertIccBasedCmyk

Also convert images in an ICC-based CMYK colour space. The embedded profile is not used, so colours can shift more than with device CMYK. Defaults to false.

Formula

How CMYK is turned into RGB. Defaults to Multiply, the closer of the two to how viewers show CMYK.

JpegQuality

The quality converted JPEGs are saved at, greater than 0 and at most 1; null (the default) keeps the quality each original was saved at.

SubsampleChroma

Store the colour detail of converted JPEGs at half resolution (4:2:0). Defaults to true.