Author Topic: Fill a shape with an image  (Read 4179 times)

November 05, 2017, 10:55:52 AM
Read 4179 times

maisieinforestburg

  • Jr. Member

  • Offline
  • ***

  • 27
I have watched a couple of videos on how to fill a shape with an image (photo), and it's not working. I'm not sure what I'm missing.

I converted a bear silhouette to vector, and I want to fill it with a photo of a forest.

I've done object to path and object to pattern on the forest image. I just can't get it to fill in the bear silhouette. What have I done wrong?


November 05, 2017, 12:19:45 PM
Reply #1

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Oh, you're very close!

In the file you shared, what it looks like you've done is correctly convert the forest image into a pattern.  (Well, at least that's one way to do it.)  But it looks like you filled a rectangular path with the pattern, instead of filling the bear shape.

The bear shape hasn't been traced yet, in that file.  Here are some steps that will work (some other steps would work too, but since you started out using a pattern, I'll stick with that technique).

1 -- Trace the bear silhouette (either auto-trace with Trace Bitmap, or trace with Pen/Bezier tool).
2 -- With the new bear path selected, click Object menu > Fill and Stroke > Fill tab > Pattern Fill  (the button looks like this :pf:)  (not this one, which is similar :gmr:)
3 -- That will open the Patterns menu, and it looks like you've converted that image to a pattern twice.  At the very top of that menu, you see pattern 3323 and pattern 5534.  Either one of those will fill the bear with the photo/pattern.

Once the bear path is filled, you might need to adjust the pattern.  Switch to the Node tool, and look around the canvas for 3 tiny handles -- an X, a square, and a circle.  You can drag the X handle with the Node tool, in case one of the edges of the pattern are in the middle of the bear.  The square handle adjusts the size of the pattern.  Hold the Ctrl key, to keep it in proportion as you drag.  And the circle handle rotates the pattern.

Once the bear is finished, you can delete the rectangle that you made earlier.

Lately it seems the pattern handles are usually close to where the photo was when you did Object to Pattern.  In the past, they could be really hard to find, but hopefully that's been fixed.  (I see them right on top of the rectangle for pattern 3323.)

  • 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                       

November 05, 2017, 01:15:11 PM
Reply #2

maisieinforestburg

  • Jr. Member

  • Offline
  • ***

  • 27
Thanks, Brynn!

I now have a final problem with this file - I'm trying to convert it to a PNG cairo format, and each time I try to do that, and find that the png is blank.  I have no idea why this is happening....it converts to  a pdf just fine......

November 05, 2017, 02:39:31 PM
Reply #3

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
I would guess there's something about the pattern which the cairo png format can't handle?

Is there some particular reason you want to save as cairo PNG instead of Export PNG?  If there's no particiular reason, I would suggest using File menu > Export PNG.  That should work as expected.

If you have to use cairo png for some reason, maybe someone else knows a trick?  I thought about using Edit menu > Make a Bitmap Copy.  I thought that would change the pattern into something which cairo png could handle.  But it didn't seem to work.
  • 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                       

November 05, 2017, 03:55:09 PM
Reply #4

maisieinforestburg

  • Jr. Member

  • Offline
  • ***

  • 27
I tried it both ways, it's not working. Exporting it gave me an error message

Here is the printscreen of that error

November 05, 2017, 04:39:45 PM
Reply #5

maisieinforestburg

  • Jr. Member

  • Offline
  • ***

  • 27
If they do manage to go through, I am getting png with black background that I can't use - what is happening with this conversion?

This is strange - on this website, it is not showing a white background. Why is that?

November 05, 2017, 04:45:16 PM
Reply #6

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Looking at your original file it is a bit strange. Bottom indication doesn't tell what's wrong with it, but the embedded images resize to their original height/width ratio and have a slightly larger bounding box.

The bear you had was also a raster image with a black silhouette over a white background -so masking wouldn't be so easy with it.


What I did: opened the file, extracted the images with the image extension, then imported them back again. Seems working after.
Trace bitmap the bear, and use that for clipping the image -grouped the first and clipped the group.


November 05, 2017, 04:47:41 PM
Reply #7

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
In addition would suggest updating to current stabile (0.92.2) here.

November 05, 2017, 07:13:35 PM
Reply #8

maisieinforestburg

  • Jr. Member

  • Offline
  • ***

  • 27
Hmm, that's strange, I thought I had changed the bear from a raster to a vector with trace bitmap. Then I threw out the raster of the bear.
The reason i threw it out and used the vector is that the forest background image i turned into a pattern would not fill into a raster. It filled the vector bear though.....
Am quite confused now

November 06, 2017, 04:35:27 AM
Reply #9

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
Maisie, when exporting any png images, make sure you do NOT have the custom tab selected. On your screenshot, it says the export area is 0 width and 0 height. Either click on the 'selection' tab at the top, or on the 'page' tab, whichever you want. Custom is for manually setting the coordinates.

November 06, 2017, 05:33:57 PM
Reply #10

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
This is strange - on this website, it is not showing a white background. Why is that?

I'm only guessing, but probably you used a Single Scan option, with Trace Bitmap.  So that means you only have one path for the result.  Since Inkscape's background is transparent by default (even though it looks white) when you export, Inkscape only "sees" the bear path.

If you want a background, you can draw a rectangle, fill it with the color you want, and put behind it.

Hmm, that's strange, I thought I had changed the bear from a raster to a vector with trace bitmap. Then I threw out the raster of the bear.
The reason i threw it out and used the vector is that the forest background image i turned into a pattern would not fill into a raster. It filled the vector bear though.....
Am quite confused now

Lazur is saying that he undid everything you had done, and started all over.  So that's why he traced the bear again.  In the screenshot you showed, with the error message, I see the bear behind it, with the forest in it.  It looks correct to me!

It's hard to say what the problem is with the export.  When you first open the Export PNG dialog, first you need to look at the 4 buttons at the top.  Inkscape can export 4 different areas -- it can export only what is selected (Selection button), or everything that is drawn on the canvas (Drawing), or just the page (inside the page border) (Page), or a custom area (Custom button).  So you need to choose which one you want.

I've never used the custom area before, so I'm not familiar with it.  But these are the options I usually use.

If it's just one thing on my canvas that I want to export, I choose Selection.  And then make sure it's selected, before clicking Export button.  If I want to show my whole drawing, no matter where it is on the canvas, I might choose Drawing.  If it happens that I have everything inside the page border, then I use Page. 

Or another thing I do sometimes.  Usually I have the page border turned off, so that when I'm drawing, I have no idea whether everything is inside the border or not.  But there's a quick fix. I select the finished drawing, then Document Properties > Page tab > Resize page to contents.  This moves the page border and resizes it to perfectly fit the drawing, all at once.  You can also add a margin.  Then I use the Page export option.
  • 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