clip and export - clip border visible?
clip and export - clip border visible?
I have a problem with clipping a bitmap in Inkscape.
After I export a clipped bitmap into PNG it looks fine. However after I print this PNG into a PDF file, insert it into LibreOffice writer (and save it into a PDF from there as well) I get a thin grey line where my clip path in Inkscape used to be. If I look carefully at the PNG file using GIMP I see that along the clip path I have a thin line of partially transparent pixels - I guess it can have something to do with it? For clipping I tried paths with 0 width, with no stroke, and it doesn't help. Any help appreciated.
I use Inkscape 0.92pre1 on Ubuntu 14.04.3 from the dev ppa.
(First I posted the question on SuperUser http://superuser.com/questions/1086816/ ... er-visible, but seems like it's not getting much attention there)
After I export a clipped bitmap into PNG it looks fine. However after I print this PNG into a PDF file, insert it into LibreOffice writer (and save it into a PDF from there as well) I get a thin grey line where my clip path in Inkscape used to be. If I look carefully at the PNG file using GIMP I see that along the clip path I have a thin line of partially transparent pixels - I guess it can have something to do with it? For clipping I tried paths with 0 width, with no stroke, and it doesn't help. Any help appreciated.
I use Inkscape 0.92pre1 on Ubuntu 14.04.3 from the dev ppa.
(First I posted the question on SuperUser http://superuser.com/questions/1086816/ ... er-visible, but seems like it's not getting much attention there)
Re: clip and export - clip border visible?
To make it pixel-perfect you need the graphic pixel-aligned per snapping to a pixel-grid:
Cheers
P.
Cheers
P.
Re: clip and export - clip border visible?
So, should the bitmap be aligned to pixels grid in Inkscape? But what if it has a totally different resolution from my inkscape document? I tried snapping both the bitmap and the path to the pixel grid, but nothing really changed...
Re: clip and export - clip border visible?
Shouldn´t make any difference.
What is what you´re exporting? Page/Drawing/Selection or Custom size? Drawing should clip it perfectly - at least here me making thousands of pixel perfect icons.
Cheers
P.
What is what you´re exporting? Page/Drawing/Selection or Custom size? Drawing should clip it perfectly - at least here me making thousands of pixel perfect icons.

Cheers
P.
Re: clip and export - clip border visible?
I'm exporting a selection, and I hide all non-selected objects. Do you think it can make a difference? I tried copying the selection to a new document and exporting Drawing, I got the same artefact...
Re: clip and export - clip border visible?
Is there any filter applied to the image?
Reducing the page size to the selection (shift+cmd+D) don´t help either?
Reducing the page size to the selection (shift+cmd+D) don´t help either?
Re: clip and export - clip border visible?
No filters, and it doesn't help 
Also, just in case, the clip is not simply a rectangle, but a more complicated shape.

Also, just in case, the clip is not simply a rectangle, but a more complicated shape.
- Espermaschine
- Posts: 892
- Joined: Thu Jun 05, 2014 9:10 pm
Re: clip and export - clip border visible?
I dont know anything about this stuff, but i wanna mention: there is an extension called Pixel Snap (under Modify Path) that aligns vectors to the pixel grid.
Why do you need to clip your image ? Cant you just trim it with Gimp ?
Why do you need to clip your image ? Cant you just trim it with Gimp ?
Re: clip and export - clip border visible?
Thanks, I'll have a look at the extension.
Well, I can, it's just I have already done everything in Inkscape and wanted to simply export what I have. If I have to, I'll do it again in Gimp of course...
Well, I can, it's just I have already done everything in Inkscape and wanted to simply export what I have. If I have to, I'll do it again in Gimp of course...
- Espermaschine
- Posts: 892
- Joined: Thu Jun 05, 2014 9:10 pm
Re: clip and export - clip border visible?
Have you thought about using your clip-shape as a layermask in Gimp ?
Just export your clip as a black and white mask and paste it into a layermask, then apply.
I mix Gimp and Inkscape all the time, with great success.
Of course you could also import a path...i do that with rendering sometimes, because the Bezier Tool is so much better than the Paths Tool in Gimp.
Just export your clip as a black and white mask and paste it into a layermask, then apply.
I mix Gimp and Inkscape all the time, with great success.
Of course you could also import a path...i do that with rendering sometimes, because the Bezier Tool is so much better than the Paths Tool in Gimp.
Re: clip and export - clip border visible?
Thanks, that's a good idea! Would save some time. I am really not that familiar with Gimp, try to use Inkscape whenever possible.
Re: clip and export - clip border visible?
I have no clue what´s going on here. I just can clip to the page/object size. Any other features are pretty sure get anti-aliased whether it´s pixel-perfect or not. And I´m not able to get corresponding page size at Document-setting and page-export and grid! No alignment consistency.
Cheers
P.
Cheers
P.
- Espermaschine
- Posts: 892
- Joined: Thu Jun 05, 2014 9:10 pm
Re: clip and export - clip border visible?
I see. There is also a technique to put an image as a pattern fill into a shape and edit the shape:
https://youtu.be/I_4ADLsGA4o
But i think that may not render so well with pdf. Not exactly sure...
https://youtu.be/I_4ADLsGA4o
But i think that may not render so well with pdf. Not exactly sure...
Re: clip and export - clip border visible?
If it's for an A4 sized document/pixels scaled to real world units the pixel grid might not match right with the page size.
The method you described in the first post is way overcomplicated in the sense of the raster images.
Yes, you can export to a raster image an object to get clean pixel edges.
Then you could embed those back in and use them instead the vectors.
There is also the option of creating a bitmap copy (Alt+B) -you can set the resolution in the preferences somewhere.
By printing to pdf, you rasterize the whole page.
If embedded raster images were off the pixel grid of that rasterization -which who knows at what dpi is at- the result will get smudged.
And if the page was like A4 sized, it just wouldn't work at all.
I'd suggest creating bitmap copies if necessary for that type of work and
saving the drawing as svg, and
using scribus to combine the svg with libreoffice and saving as pdf in scribus.
Then probably you could get to the best result.
The method you described in the first post is way overcomplicated in the sense of the raster images.
Yes, you can export to a raster image an object to get clean pixel edges.
Then you could embed those back in and use them instead the vectors.
There is also the option of creating a bitmap copy (Alt+B) -you can set the resolution in the preferences somewhere.
By printing to pdf, you rasterize the whole page.
If embedded raster images were off the pixel grid of that rasterization -which who knows at what dpi is at- the result will get smudged.
And if the page was like A4 sized, it just wouldn't work at all.
I'd suggest creating bitmap copies if necessary for that type of work and
saving the drawing as svg, and
using scribus to combine the svg with libreoffice and saving as pdf in scribus.
Then probably you could get to the best result.
Re: clip and export - clip border visible?
I would like to work on solving this for you as it might affect everyone, can you upload an svg that shows this problem as well as the output png? I am thinking the prefs might have some bearing on the matter.
Your mind is what you think it is.
Re: clip and export - clip border visible?
Thanks everyone for the suggestions.
druban, please find svg, png and pdf (printed png) files here: https://yadi.sk/d/Uon26JECsNKWs The svg file has one bitmap image in it with a clip. Would be great if you could figure it out.
druban, please find svg, png and pdf (printed png) files here: https://yadi.sk/d/Uon26JECsNKWs The svg file has one bitmap image in it with a clip. Would be great if you could figure it out.
Re: clip and export - clip border visible?
In the meanwhile...
You`ve used very odd 0.125 thickness for the stroke. Aside of that, stroke does not affect clipping so there`s no need for stroke/s on clipping masks - hence, after I removed it, everything worked as expected.
I`m not sure if IS and Scribus share the exporting routines, but since the unwanted line on the pdf is not of the same width, I presume it`s due to the antialiasing.
You`ve used very odd 0.125 thickness for the stroke. Aside of that, stroke does not affect clipping so there`s no need for stroke/s on clipping masks - hence, after I removed it, everything worked as expected.
I`m not sure if IS and Scribus share the exporting routines, but since the unwanted line on the pdf is not of the same width, I presume it`s due to the antialiasing.
Re: clip and export - clip border visible?
Are you saying it works for you with no stroke? I have tried it, I still get that weird line in the pdf. What version of Inkscape are you using?
Re: clip and export - clip border visible?
0.45, but still - as mentioned - stroke does not affect clipping so you really don`t need it on clipping mask.
Re: clip and export - clip border visible?
OK, I'm wondering whether it's a regression in the newer version of Inkscape then, thanks.
Re: clip and export - clip border visible?
Weird, I tried the pattern approach and have the same issue - the lines where the stroke of the new object would have been are visible in PDFs...
Re: clip and export - clip border visible?
Having a white background rectangle helped!