Skip to content

Compress: Expand colorspace handling for images and make processing more generic #54

Closed
@gunnsth

Description

@gunnsth

Currently the colorspace handling only supports DeviceGray and DeviceRGB and the handling is simplistic only looping through the images in XObject and compressing all of those. If any image was never used in the contentstream it would still not be removed for example.
Also this means that inline images are not handled.

The handling should be made more generic and use the ContentStreamProcessor to process the contents. The colorspace handling should also be more generic and fall back to alternative colorspaces in cases where not properly supported. The handling should be similar as for example in:
https://github.com/unidoc/unidoc-examples/blob/v3/pdf/advanced/pdf_grayscale_transform.go

although we can ignore handling of patterns and shadings at the moment.

Take care to remove resources that are not used. Perhaps that should be its own optimization as it makes sense to remove images, fonts, colorspaces or any other resources that are not actually used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compressCompression / OptimizationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions