GIMP: Background removal gives gray fringe, when exported as PDF

I cut a region out of this Wikimedia Commons picture:
cout-out

I simply used the free select tool to cut out the part (ctrl+x) and inserted it into another image without background.

However, when I export the project as PDF (File → Export as → Select file type → PDF), I get gray fringes around the border of the cut-out:

gray fringes

Closer look:

closer look at the gray fringe

Why do these fringes appear? The image looks perfectly normal in GIMP, as shown in this picture:

looks like no fringe inside gimp

Also in my default image viewer, when exported as PNG, the borders look perfectly normal:

PNG shows no signs of gary fringes, or does it?

Why do these fringes appear? Is there a way to remove them?

Answer

The gray fringe appears at the boundary between “opaque white pixels” and “transparent pixels”.

When you zoom in, GIMP is showing each pixel as a large square which is either white or transparent, so it appears to be OK.

When you zoom in a PDF document, the PDF engine smooths the image so that squares do not appear. So it has to smooth both the color (RGB channels) and opacity (the alpha channel). And here it surfaces that transparent pixels also must have some color to be interpolated. In most cases the “color” of transparent pixels turns out to be black. As a result, halfway between centers of white and transparent pixels you get a half opacity and a half-white, half-black color, which yields this very gray fringe.

One possibility to solve this is to make transparent pixels not fully transparent. In GIMP, add a new layer below the current one, fill it with white color, and make it “almost transparent” (opacity 1 of 255). It will become invisible to the eye. Then, flatten your image and export to PDF. Since the “transparent” pixels are now not fully transparent, they will retain their original white color which will always interpolate as white.

Attribution
Source : Link , Question Author : Wamseln , Answer Author : Goblin Alchemist

Leave a Comment