Crop rather than clip a complex vector graphic

Post questions on how to use or achieve an effect in Inkscape.
Anark
Posts: 7
Joined: Sat Jul 26, 2008 6:33 pm

Crop rather than clip a complex vector graphic

Postby Anark » Sun Nov 14, 2010 9:26 pm

I would like to remove permanently certain areas from a vector graphic without needing to apply an intersection to every single path or merely hide the area using Object > Clip > Set.

The method of clipping and then fitting the page to selection <http://inkscape-forum.andreas-s.net/topic/112456> doesn't do anything for me -- I can always release the clipped area and bring it back. I want it gone for good to cut down on file size and processing load.

Any advice?

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Crop rather than clip a complex vector graphic

Postby brynn » Mon Nov 15, 2010 6:36 am

This is a question we get a lot here, and I recently wrote an overview, sort of article, to address the many different ways the question is asked: Transparent Background and Cropping (or Rendering) in Inkscape.

However, I doubt you will find a solution that's acceptable to you. Clipping is how Inkscape handles this, with a few exceptions, which are discussed in the above article/tutorial. That said, you could still show us your image, if you like, and we might be able to come up with some unique combination of techniques. It's hard to say, without knowing what's in your image. But by your description, I suspect Inkscape cannot do what you want.

Thinking outside the box - I don't suppose scaling down the whole image would work for you?

Sorry, I wish I could be more help :(

Guest

Re: Crop rather than clip a complex vector graphic

Postby Guest » Mon Nov 15, 2010 9:04 am

Thanks, Brynn!

And no, I don't think your tutorial addresses my problem, which seems to come down to a piece of functionality missing in Inkscape.

There's a recent discussion on the Inkscape developer list where a crop feature is requested and some developers question the need for it.[1] To me, the obvious usefulness of the feature lies in the preservation of system resources and time: I don't want my computer to deal with several megabytes' worth of useless hidden SVG nodes every time I modify the regular nodes in any way.

I've run up against this limitation time and again. Currently I'd like to use a 6+ megabyte piece of clipart that has four differently coloured instances of the same design copied into one SVG file.[2] A look at the source code reveals that nearly 2 megabytes' worth of source code is pointless cruft that Adobe Illustrator's SVG export process dumped at the end of the file. But even with this stuff removed, I have four instances of the same thing when I only want one, each weighing in at more than a megabyte. I want to remove three of those four, and deleting every single path individually is clearly not an option.

In this particular case, I will probably be able to remove the unwanted instances by editing the source, but in many other cases, the stuff I want to remove is not so neatly delimited.

---------------------
[1] <http://www.pubbs.net/201010/inkscape/24457-re-inkscape-devel-crop-tool-should-be-straight-forward-to-implement-thoughts.html>
[2] <http://www.dragonartz.net/2009/04/20/colored-pattern-background-vector/>

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Crop rather than clip a complex vector graphic

Postby brynn » Mon Nov 15, 2010 10:50 am

Yes, I understand what you mean. I can't speak to the development issues, but I understand the need to do a traditional crop.

It really does help to see your image though, as far as making suggestions. So you want to separate out the upper image (on the webpage you linked) from the lower image. It's hard to know for sure without having the SVG file to look at, but it does look to me like you might be able to get this job done fairly quickly and easily. From what I can tell, by zooming my browser, those 4 quadrants are not connected at all! Unless that's just an example, and not the specific image you want to crop?

I don't suppose Vacuum Defs would remove any of the extra stuff added by AI's SVG export? That would probably too easy, lol!

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Crop rather than clip a complex vector graphic

Postby druban » Mon Nov 15, 2010 12:17 pm

this is not the perfect solution, but Inkscape has a 'select inverse', so you could draw your cropping area with the selection tool and then select inverse and delete. This is useful for cleaning up at the end of a project etc. Clearly this does not work if you want only part of any path. In addition, the selection of paths partly outside the selection area requires you to alt select as well and gets a little tricky, but Inkscape does not seem to have a rubber band selection option that selects all objects that have any part within the selection area instead of objects that are entirely within, which might help in this case.
Your mind is what you think it is.

Anark
Posts: 7
Joined: Sat Jul 26, 2008 6:33 pm

Re: Crop rather than clip a complex vector graphic

Postby Anark » Mon Nov 15, 2010 7:32 pm

Brynn -- I want to separate those four quadrants and use any one or two of them in a design. As there aren't any overlapping paths, this would look like the simplest of possible cases, but I'm still at a loss. I've removed the AI stuff in a text editor and zipped up the SVG to 1.2 MB: <http://inter.textdriven.com/gfx/tiles.zip>

Druban -- I couldn't do what you suggested. Could you demonstrate your solution on the file linked above?

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Crop rather than clip a complex vector graphic

Postby druban » Tue Nov 16, 2010 5:26 am

Hi Anark. I hope your 'puter is faster and more loaded than mine because this file was slow to work with.
First, I ungrouped three times without deselecting in between.
This gave me anumber of groups that seemed to reflect accurately the graphic. I clicked on one quadrant since it seemed easier than drawing a selection rectangle and it was. Here is the pic it doesn't tell you much but the top left quadrant is selected (sorry about the res, but the forum limits the size of uploads) ...
g75220.png
top left selected
g75220.png (45.63 KiB) Viewed 20215 times

Then I do select inverse (edit menu) now everything else is selected, the other three quadrants as well as some "cruft" to use your term.
g75229.png
other three selected
g75229.png (153.26 KiB) Viewed 20215 times

now I press the delete key and this is what you want right?
g75238.png
top left remaining
g75238.png (14.44 KiB) Viewed 20215 times
Your mind is what you think it is.

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Crop rather than clip a complex vector graphic

Postby druban » Tue Nov 16, 2010 5:36 am

(cont'd.)
and just to test things, undo, select bottom right, invert, delete
g93211.png
g93211.png (16.34 KiB) Viewed 20215 times


Incidentally, I removed the "cruft" (by selecting just the four quadrants by shift-clicking on each, doing select inverse, and deleting the invisible stuff) and the extra defs (file: vacuum defs) and your filesize is now 5630KB (slightly larger???).
Compressed with 7Z it is only 662KB.
zipped it is 1286KB.
The forum will not allow me to upload any of these files but if you want me to email it to you I guess you can message me with your email. Let me know if you can't parse a 7Z archive.
Dru

edited later: And then I thought, why not try and see what one quadrant weighs in at? So here it is:
tiles1.7z
(207.93 KiB) Downloaded 303 times

And another:
tiles2.7z
(192.2 KiB) Downloaded 229 times


Incidentally, the file saved with the extra stuff removed, the graphic ungrouped, and the defs vacuumed opens and handles much faster in Inkscape. Even though t is a few KB bigger. Go figure.
Your mind is what you think it is.

Anark
Posts: 7
Joined: Sat Jul 26, 2008 6:33 pm

Re: Crop rather than clip a complex vector graphic

Postby Anark » Wed Nov 17, 2010 10:07 pm

Thanks, Druban!

The magical incantation of ungrouping thrice hadn't occurred to me, and things get pretty trivial from there, of course.

This neatly solves the problem at hand but doesn't do anything about the lack of cropping functionality that would allow me to cut across multiple paths in one go. That, however, is a worry for another day.

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Crop rather than clip a complex vector graphic

Postby druban » Thu Nov 18, 2010 6:36 am

That is a bit of a problem, I admit. have you tried the eraser tool? It has two modes, and one of them will cut across paths. There are a great many limitations of this tool, however, so use it with caution. In particular, unclosed paths may be a source of some frustration (or amusement).
Your mind is what you think it is.

Anark
Posts: 7
Joined: Sat Jul 26, 2008 6:33 pm

Re: Crop rather than clip a complex vector graphic

Postby Anark » Sat Nov 20, 2010 2:11 am

Thanks, this might come handy.

thinkinghorse
Posts: 1
Joined: Fri Jun 12, 2015 10:57 pm

Re: Crop rather than clip a complex vector graphic

Postby thinkinghorse » Fri Jun 12, 2015 11:09 pm

For a bitmap, crop your image as per instructions above then select it and then click on the menu

Edit > Make a Bitmap Copy

This saves a file in the folder the original file was loaded from. Then import this bitmap and use it to replace the previous bitmap. It is genuinely clipped i.e. no invisible data hanging around.

Paulgieske
Posts: 1
Joined: Sat Apr 16, 2016 8:31 pm

Re: Crop rather than clip a complex vector graphic

Postby Paulgieske » Sun Apr 17, 2016 4:58 am

HI, I know this is an old post, but have you tried this multi-bool extension?
https://inkscape.org/nl/~Moini/%E2%98%8 ... e-division
I think it's what you are looking for

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Crop rather than clip a complex vector graphic

Postby brynn » Mon Apr 18, 2016 5:15 am

Interesting extension!

But it probably did not exist when the original message was posted.

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

Re: Crop rather than clip a complex vector graphic

Postby Moini » Mon Apr 18, 2016 5:21 am

No, I've only posted it to inkscape.org a few days ago - the original extension by Ryan Lerch existed, 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)


Return to “Help with using Inkscape”