How to remove clipping with command line?

Post questions on how to use or achieve an effect in Inkscape.
theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

How to remove clipping with command line?

Postby theozh » Thu Dec 08, 2016 7:33 pm

I am importing PDF files via Inkscape command line and saving them as SVG. This seems to work.
- The resulting SVG has then a "Group of 1 object"; clipped in root.
- This SVG is not displayed e.g. when imported into LibreOffice, just an empty area instead

Now, I found out if I manually select this group in Inkscape-GUI, ungroup it...
- I get e.g. a "Group of. 1133 Objects"
- this group seems to be not clipped anymore
- if I save the SVG again, the file is displayed correctly in LibreOffice.

So the "clipping" seems to be the problem. Strange enough, some files show a "clipping" and some not.
However, I do not want to remove the clipping manually for every file.

Therefore, I tried the following command line:

Code: Select all

inkscape -z -f "Input.pdf" --verb EditSelectAll --verb SelectionUnGroup -l "Output.svg"

However it says:

Code: Select all

WARNING: ignoring verb EditSelectAll - GUI required for this verb.

** (inkscape.exe:3320): CRITICAL **: static void Inkscape::EditVerb::perform(SPA
ction*, void*): assertion 'ensure_desktop_valid(action)' failed
Select a <b>group</b> to ungroup.
<b>No groups</b> to ungroup in the selection.

Questions:
1) Where does this clipping come from?
2) How to avoid or remove the clipping with command line and without GUI?
Win7/64, Inkscape 0.92.2

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to remove clipping with command line?

Postby Moini » Fri Dec 09, 2016 12:13 am

ad 1) The clipping comes from the pdf import. In my observation, pdfs are (always?) usually clipped to their page size when imported into Inkscape, probably to make them look exactly as they did when they were still a pdf. As LibreOffice can import pdfs, why don't you import directly?

Now these are the solutions I can think of:
ad 2) Option a) Use a different tool. The easiest way I can imagine would be to write a script that removes the clip for the outermost group by removing the clip from the defs, and the clip-path attribute from the group.
or:
Option b) Redirect the GUI somehow. I think there are ways to simulate to a program that it is running in GUI mode - don't know how exactly, but I've read about it only recently.
or:
Option c) Ask Dmitriy about his addition to Inkscape, see https://sourceforge.net/p/inkscape/mail ... sg35040526 (I think EditSelectAll is not included, but if someone asks, he might add it).
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to remove clipping with command line?

Postby theozh » Fri Dec 09, 2016 1:43 am

Thanks @Moini,

ad 1) LibreOffice Writer cannot include PDFs as an image! At least not my Version Win7/64bit 5.2.3.3.
I am not talking about LibreOffice Draw, it can import PDF, but the PDFs are not displayed correctly, i.e. unusable!
That's why I need SVG.

ad 2)
a) That's what I did in the meantime. Since I have to use Perl anyway earlier, it doesn't matter if I replace a few lines of SVG-Code more. Without exactly understanding the SVG-code, that's what I did: remove the "clipPath" lines with Perl-Code:

Code: Select all

$SVG =~ s/<clipPath.+?clipPath>//gs

So far, just in the defs and it seem to help ;-).
b) not preferred, too uncertain
c) might not be necessary anymore, since I have full flexibility with modifying the SVG via Perl.
Win7/64, Inkscape 0.92.2

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to remove clipping with command line?

Postby Moini » Fri Dec 09, 2016 2:48 am

Additionally, you can remove the lines that look like this, to retain a fully valid SVG (it also works without that modification, but the program will be looking for a clip path that does not exist):
clip-path="url(#someID)"

On the positive side, the perl script has a lot less overhead than if you would have scripted Inkscape ;-)
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to remove clipping with command line?

Postby theozh » Fri Dec 09, 2016 5:51 am

Thanks again, @Moini
well, I have to look more in detail and try to understand SVG better
I thought I have to remove the complete <g clip-path ... > bracket.

Code: Select all

<g clip-path="url(#clipPath12)"
     transform="matrix(0,1.25,1.25,0,0,0)"
     id="g10">

However, then the image ist rotated an mirrored ;-)
So the transform= ..." should not be deleted. Obviously, only the "clip-path=" as you certainly meant.
Win7/64, Inkscape 0.92.2

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to remove clipping with command line?

Postby Moini » Fri Dec 09, 2016 6:34 am

LOL, yes :) Weird things happen when one is learning ;-) (seems you're careful and working with copies, which is always a good idea).
What will you do with those images in the end?
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to remove clipping with command line?

Postby theozh » Fri Dec 09, 2016 6:10 pm

Well, the original idea was/is to bring music notes in *vector format*(!) into a word processing program, i.e. LibreOffice Writer. The original question was: which format? EPS does not work anymore since LO Writer 4.0, PDF could not and still cannot be imported. So, the only format seems to be SVG. But there were quite a few hurdles to overcome :evil: , e.g. a mess with non-Unicode (notation program) and non-Unicode (Inkscape) fonts (see this post. Is there really no option to handle non-Unicode fonts with Inkscape?), and many things more... It really was (fortunately was(!) :D ) a pain! ...printing to a PS-printer, converting to EPS and to PDF, load the PDF and convert to SVG and do some corrections... Phew!
Now this "clipping" issue is just a minor detail ;). In the end SVG seems actually better than EPS because you can modify it in Inkscape with quite a few tools and fortunately LibreOffice Writer can include it correctly.
DoReMi.png
DoReMi.png (29.95 KiB) Viewed 4114 times
Win7/64, Inkscape 0.92.2

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to remove clipping with command line?

Postby Moini » Sat Dec 10, 2016 5:56 am

Those look nice! Thank you for sharing the story (and the bumps along the way, too).

If you need more elaborate note-setting(?) tools, be sure to take a look at musescore (it can also export to svg ;-) ): https://musescore.org . I've seen many favorable reviews, never needed something like that myself, though.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to remove clipping with command line?

Postby theozh » Sat Dec 10, 2016 7:07 am

Thanks @Moini, for your help and also the Musescore hint.
Yes, I've heard of Musescore earlier and I also had it once installed. At that time, I was not fully convinced, but maybe because I was using the other program already for more than 15 years. But from time to time, one should check again, whether an alternative has surpassed your working horse in terms of compatibility, user-friendliness, support and others...

So, coming back to the original question: "removing clipping with Inkscape command line?"...
It is actually not solved (at least Inkscape internally), so I cannot mark the topic as [solved].
But, maybe, I should mark it with [3rd party workaround solution]? ;)
Win7/64, Inkscape 0.92.2

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to remove clipping with command line?

Postby Moini » Sat Dec 10, 2016 8:27 am

3rd party? I thought you wrote the script yourself :) But yes, Inkscape cannot currently solve that problem.

This one is the related bug report: https://bugs.launchpad.net/inkscape/+bug/843260 - and what worries me is that apparently someone offered to help with this, but that there hasn't been an answer... (at least not a publicly recorded one) :-/
It's a thing that is asked on the forums and the mailing lists a couple of times a year, not an uncommon issue. There are also a couple of related reports, about one or the other verb not working on command line without GUI, and some verbs just opening dialogs, and there not being the possibility to enter options for the verbs. Looks like a lot of work...
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to remove clipping with command line?

Postby theozh » Sat Dec 10, 2016 9:07 am

Well, with 3rd party I meant Perl (besides me and Inkscape) ;-).
It's good to have a workaround unless you can wait until it is fixed the way it is expected to work. But sometimes this will not happen within years. And often, if you go for a workaround you need another additional workaround and so on...

If you are interested in more details and the craziness about (in)compatibility of hard- & software and software bugs and workarounds, you'll find my conclusions and instructions of the above mentioned "vector format music notes to word processing story" under
www.beierlein.ch/Musik/Noten/Capella (unfortunately in German only).
I would be grateful for hints to shorten and simplify the process.

By the way, this finally answers another earlier question of mine in this forum:
Is there anything like a SVG-Printer?
Win7/64, Inkscape 0.92.2

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to remove clipping with command line?

Postby Moini » Sat Dec 10, 2016 9:39 am

Holla, die Waldfee... Ich ziehe den Hut vor soviel Engagement und Durchhaltevermögen! (und finde es immer wieder superspannend, was Leute so mit Inkscape anstellen - auch wenn es hier nur ein kleiner Teil des Gesamtworkflows ist)

Wow! I salute you for this amount of commitment.

Who is going to benefit from those music sheets?
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: How to remove clipping with command line?

Postby v1nce » Mon Dec 12, 2016 8:37 pm

theozh wrote:
If you are interested in more details and the craziness about (in)compatibility of hard- & software and software bugs and workarounds, you'll find my conclusions and instructions of the above mentioned "vector format music notes to word processing story" under
www.beierlein.ch/Musik/Noten/Capella (unfortunately in German only).
I would be grateful for hints to shorten and simplify the process.


does not work in chrome

chromebug.jpg
chromebug.jpg (73.76 KiB) Viewed 3923 times

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to remove clipping with command line?

Postby theozh » Wed Dec 14, 2016 12:12 am

Hi @v1nce,
sorry, it's NOT a browser issue. It's my fault. :oops:
It's simply because you do not have the necessary font on your disk. I did not think of it because on my computer it's of course displayed fine because I have this music font.
SVGs are obviously not like PDFs which can have embedded subsets of the fonts. But maybe they can have? I don't know.

The lower two sketches looked actually fine because they are already converted into paths.
If I convert all to paths it should be fine. I've changed the SVG now.
Win7/64, Inkscape 0.92.2


Return to “Help with using Inkscape”