Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace color_space field in ImageXObject with color_type field #120

Open
anhtumai opened this issue May 8, 2022 · 2 comments
Open

replace color_space field in ImageXObject with color_type field #120

anhtumai opened this issue May 8, 2022 · 2 comments

Comments

@anhtumai
Copy link

anhtumai commented May 8, 2022

ColorSpace is just a simplified version of ColorType and is not used much in this library codebase.

image

Replacing it with the color_type field in ImageXObject will give library users more information, in case they want to do some transformation with the field image_data.

For example, some people reported that adding an image with the Alpha channel will result in a blank page (#84, #119).
This can be resolved by removing the alpha channel from ImageXObject::image_data (check this comment: #119 (comment)). However, for different color_type, image_data will have different formats. For ColorType::Rgba8, image_data will have format: [Red1, Green1, Blue1, Alpha1, ..., RedN, Green2, Blue2; AlphaN]. But for ColorType::Rgba16, the format will be [Red1a, Red1b, Green1a, Green1b, Blue1a, Blue1b, Alpha1a, Alpha1b, ...]. Source: image-rs/image#1711 (comment)

@anhtumai
Copy link
Author

anhtumai commented Nov 3, 2022

@fschutt btw, do you plan to rewrite this library to not use lopdf? To me, lopdf lacks good documentation, which can be an obstacle for people to contribute.

@fschutt
Copy link
Owner

fschutt commented Feb 28, 2023

No, I don't think I'll switch from lopdf as it's still a pretty good crate.

The reason I wanted my own ColorType is because PDF doesn't support all color types that the image crate supports, the image crate also changes a lot and I don't want to break the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants