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

Problem adding grayscale jpeg file to pdf document with ImageSharp 2.x #441

Open
Edminsson opened this issue May 17, 2024 · 1 comment
Open

Comments

@Edminsson
Copy link

I have a jpg image (JFIF) that uses grayscale (has one color component according to exiftool). Everything works well when I add my image to a pdf document with the current version of PdfSharpCore. But to fix the vulnerabilities in SixLabors.ImageSharp I've updated the ImageSharp nuget to version 2.1.8. When I add the same image to a pdf document the resulting pdf is not displayed correctly and Adobe Acrobat Reader says "Unsifficient data for an image". In version 1.0.4 of ImageSharp the grayscale image is converted to use 3 color components and then ColorSpace DeviceRGB seems to work, but in version 2.x.x the Image is not converted and it keeps the single color component and then ColorSpace DeviceRGB does not seem to work. I've manually changed the ColorSpace of my faulty pdf to DeviceGray and then it works.
As far as I understand JFIF images always use DeviceRGB when added to a pdfDocument in PdfSharpCore.

@Edminsson
Copy link
Author

The latest version of SixLabors.ImageSharp behaves the same way.
Fortunately @TonyValenti has created a PR (#427) that handles this problem. In the .NET version of the class ImageSharpImageSourceImpl he calls ImageSharps SaveAsJpeg method asking for an image with the correct ColorType thus solving the problem.

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

1 participant