PDF export: Edge of image cut off by automatically added mask when `image-rendering: crisp-edges` is set
Summary:
Raster graphics in an Inkscape SVG document sometimes get a mask applied when exporting the document as PDF that cuts off the edge of the image.
From the existing similar issues, the one reported here seems to differ as follows:
- Other than in #4868 (moved), which might be most similar with respect to the size of the cut-off area, the image has not been rotated.
- Other than in inkscape#694 (closed), the object is not masked initially. Also, the referenced issue has been resolved by inkscape!5000 (merged) more than a year ago, so I assume the fix is already part of the Inkscape version with which I encountered the problem. As the merge request mentions rounding problems not completely being resolved, it might nevertheless be a starting point.
- Other than in inkscape#3998, which is said in the comments to be specific to multi-page documents, the problem occurs in single-page document as well
- Other than in #6899, there are no other masks in the document that is to be exported
- Other than in #9295, only the edge of the image disappears, not most of the image
Steps to reproduce:
- Have an image available which, when zooming in, easily allows to see if anything is cut off. An example is provided below in the samples section.
- Open Inkscape
- Embed the image into the document, or use one of the supplied documents in the sample section below
- Save the document as PDF (using
File
menu,Save as
)- It seemed not to make a difference whether the recommended rounding compensation is chosen or not
- Other parameters left at default values
- Open the PDF in a viewer for visual inspection
- Optionally: Re-import the PDF to Inkscape for inspection
What happened?
- In many cases, like the ones provided above, some edges of the image where cut (resulting in a white gap between the blue image and the red squares)
- Example:
- Sometimes, like when setting the image position to the origin (0, 0), no cutting is visible. Using integer values for the position (in px) seems to increase the chance of having no cutting visible, compared to using arbitrary drag-and-drop positions, but is not sufficient.
- The problem seems to (potentially) occur regardless of whether the image is scaled down, up or used at its original size (see provided examples)
- Example:
- Regarding the optional step: A mask has been applied to the image, which is responsible for the missing edge area
- The mask is a path of 5 nodes, arranged as a rectangle (two nodes probably being at the same position)
- I could not see a pattern in the size of the cut-off area. In particular, integer-px-sizes of the image were clipped to non-integer sizes, and the cut-off size sometimes was larger than a pixel of the embedded image.
What should have happened?
- The image should have been completely visible, like in the following (blue image touches the red squares):
Sample attachments:
- Sample image for inspection of edges being cut off
- SVG documents containing the image and producing the issue:
- Exported PDFs
- Re-import from PDF to Inkscape, using the Cairo-based import:
Version info
Inkscape 1.3.2 (091e20ef0f, 2023-11-25)