You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code incorrectly sets the color_space to DeviceN for RGBA images. RGBA should be convert to RGB before embed, then use DeviceRGB color space instead of DeviceN
I have preliminarily resolved this issue, they works good in my local project.
I plan to make a PR, but I noticed this interesting comment in the code:
Description
Grayscale JPG
not display at allGrayscale PNG
display incorrectly/with abnormal appearanceRGBA PNG
not displaying at allMinimal Reproduction Project
embed-img-to-pdf-err.zip
lopdf Version
0.34.0
Additional Information
In fact I have found the cause of this issue
Grayscale Image
Not Displayinglopdf/src/xobject.rs
Line 75 in 34e2d20
The code incorrectly divides
bits_per_pixel
by3
for all image types.For grayscale images,
bits_per_pixel
is8
and should not be divided by3
.RGBA PNG
Not Displayinglopdf/src/xobject.rs
Line 83 in 34e2d20
The code incorrectly sets the
color_space
toDeviceN
forRGBA
images.RGBA
should be convert toRGB
before embed, then useDeviceRGB
color space instead ofDeviceN
I have preliminarily resolved this issue, they works good in my local project.
I plan to make a PR, but I noticed this interesting comment in the code:
lopdf/src/xobject.rs
Lines 71 to 75 in 34e2d20
3
is actually causing issues with grayscale imagesBefore submitting the PR, I'd like to understand:
The text was updated successfully, but these errors were encountered: