Author Topic: Find rectangles in image and create selectable rectangles  (Read 785 times)

July 20, 2018, 06:37:07 PM
Read 785 times

Ivankov

  • Sr. Newbie

  • Offline
  • **

  • 4
I have an image. The image is just a white background with about 20 black rectangles. Is there a way for inkscape to find the rectangles and create selectable rectangles similar to  how I could create using the rectangle square tool? this way I can fill them and resize them etc..
  • 0.91
  • Windows 10

July 20, 2018, 07:47:20 PM
Reply #1

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Welcome to the forum!

I'm not clear what you're asking.  Is the image an imported raster image consisting of 20 black rectangles?  Or are they vector rectangles?

If they are vector rectangles, they are already selectable.  There are several ways to make a selection in Inkscape.  One is to drag the Selection  tool :sel: around all of them.  Or you could hold the Shift key while you click on  each one, one at a time.  Or there are some other less known ways.  If there are a lot of other contents in the file, you could use Edit menu > Find, to select only the black rectangles.  (And still other ways too!)

If you want to create more rectangles, you could select all of those 20, and simply Edit menu > Duplicate (or use the button :dup: or use the key shortcut Ctrl + d).  If you don't want 20 more, you can select however many you need and duplicate them.  Note that when you use duplicate, the new ones are created exactly on top of the originals.  So you'll have to drag them away.  If you drag them away immediately after duplicating, you can move them all at once, and not have to do it one at a time. 

Or you might want to clone them, if you're thinking of many more rectangles....although if you clone them, they can only be one color, they can't have different colors.  Hhmm, well that's not entirely true.  If you use Edit menu > Clones > Tiled Clones, you can set them up to have different colors.  But that might be a little more advanced than what you need, right now, since I'm not positive what you need yet.

If the image with black rectangles is a raster image, you won't be able to select them at all.  But you could use Path menu > Trace Bitmap, to make them into vector objects. 

Or you could forget about using the vector image at all, and just draw rectangles using the Rectangle tool.  For example, draw one rectangle.  Duplicate it.  Select the first rectangle and the 2nd one, and duplicate those.  Now you have 4.  Duplicate those, you have 8, then 16, then 4 more, and  you have 20.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

July 21, 2018, 08:09:46 AM
Reply #2

Ivankov

  • Sr. Newbie

  • Offline
  • **

  • 4
Thanks Brynn.

Wow that was more info than I was looking for but I can't wait to play with the features you mentioned.

It's a non vector image. So I think turning them into vector objects via trace bitmap might be the way to go. Does that always find them? What would prevent it from turning my rectangles into selectable vectors if I use  trace bitmap?
  • 0.91
  • Windows 10

July 21, 2018, 09:14:38 PM
Reply #3

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
I guess the only thing that would prevent Trace Bitmap from creating vector paths would be the quality of the image.  If it's a very small image, or the image is very grainy or fuzzy or blurry, it might not work.

When you say "find them" I'm not sure what you mean.  If you can see them, Inkscape can "see" them....unless again, it's a blurry image, or very small.  If they are solid black rectangle, there should be no problem.  If they are rectangular lines, and the lines are very thin or narrow, it might be tricky.

You're welcome to share the image, if you like.  Or you could just fire up Inkscape, import the image, and give it a try.

Just to be very clear, it doesn't change the raster image at all.  But it creates new vector paths which look like the raster image.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann