Switch to full style
Ask all general Gimp related questions here
Post a reply

Scaling paths?

Wed Oct 19, 2011 6:54 pm

GIMP Version: 2.6.11
Operating System: Windows
OS Version: Win 7 - 64 bit
GIMP Experience: Advanced Level



This is something I never tried before, and is probably quite simple. I'm just having a brain spasm about it, so I figured I'd ask.

If I take a basic graphic image/shape and enlarge it, the edges tend to get tiled, which is standard for raster graphics. But if I make a selection of a graphic image and make a path from the selection, I should be able to enlarge the path and in essence make a cleaner, larger version of the same basic image/shape, from the enlarged path. Does anyone know how I could go about doing this? I would think Gimp can do it, but I'm not sure.

Thanks in advance,

Greg

Re: Scaling paths?

Wed Oct 19, 2011 7:06 pm

As long as your path is from a selection fill (single color) this can be done PM. Then scale the path and fill it. :)

Re: Scaling paths?

Wed Oct 19, 2011 7:22 pm

A path will enlarge along with its image. The first image is 300x300 and I drew a path in it that takes up most of the image. Then I scaled the image to 500x500 and the path enlarged along with it.

Image Image

Re: Scaling paths?

Wed Oct 19, 2011 7:23 pm

I just realized what those buttons are for at the top of the tool options. PhotoMaster jedi-mindtricked me into learning some thing new. He's sneaky like that...

Image

Re: Scaling paths?

Wed Oct 19, 2011 10:06 pm

Thank you muchly! I tried it and it did work, although creating a selection from the enlarged path was still blocky. So I created a selection from the enlarged path, and created a new path from the selection. Then finally I created a new selection from the new path and when I filled the selection, it was smooth! No blockiness!

Re: Scaling paths?

Thu Oct 20, 2011 3:35 am

I was going to suggest just that.
Take your path and create a selection from it, enlarge that and re save as path again. :)
Then stroke or fill the path.

Re: Scaling paths?

Thu Oct 20, 2011 4:59 am

PhotoMaster wrote:Thank you muchly! I tried it and it did work, although creating a selection from the enlarged path was still blocky. So I created a selection from the enlarged path, and created a new path from the selection. Then finally I created a new selection from the new path and when I filled the selection, it was smooth! No blockiness!
You must have missed something ... because if you scale a path up and stroke it (or Select from path+Fill) the result is sharp and clean. In fact your method may look smooth, but it also rounds off sharp edges. Here is a comparison of the various methods to get a 5x enlargement. To my naked eye, even with zooming, I don't see any difference in quality between the last three, that are:

- Path from font size 20 blow up 5 times, selected and filled
- Path from font size 100, selected and filled
- Output from the Text tools (font size 100)

(there may be a minute shape difference if the font in size 100 isn't exactly the size 20 one blown up 5x).
ScalePath.png
ScalePath.png (28.77 KiB) Viewed 11284 times

Re: Scaling paths?

Thu Oct 20, 2011 7:38 am

Thanks for a timely thread. Good info!

Stroking the path does what stroking the selection with a paint brush is supposed to do, but doesn't.

Re: Scaling paths?

Thu Oct 20, 2011 8:31 am

When creating paths from selections, you can use the advanced options. Shift-click the "selection to path" icon and it brings up the advanced options window.

What I do is I just switch "align treshold" and "error treshold" to minimum, this way the selection-to-path conversion seems to be much more accurate.

Then just scale the resulting path to whatever size you want with the scale tool, and you're all set.

Also, this way you can also adjust the corner tresholds, to choose which corners will be rounded and which won't.

Re: Scaling paths?

Thu Oct 20, 2011 8:45 am

Nice info DD thanks!

Re: Scaling paths?

Thu Oct 20, 2011 9:04 am

:ditto
Cool info dd, thanks!

Re: Scaling paths?

Thu Oct 20, 2011 12:07 pm

GnuTux wrote:Stroking the path does what stroking the selection with a paint brush is supposed to do, but doesn't.

When GIMP paints colors onto a layer, it does so with sub-pixel accuracy (unless the Pencil is used). What this means is that if you specify coordinates with fractional components, GIMP shades the neighboring (integral) pixels by proportional amounts of the specified color as shown in the following diagrams:

sub-pixel-paint.png
sub-pixel-paint.png (8.91 KiB) Viewed 2137 times


Unless you are zoomed into the image to see those discrete pixels, your eyes will interpolate the amount of color in each of the neighboring pixels and the end result is that you perceive the full color as appearing proportionally at a single point "between" the pixels. I'm sure you are aware of all this, but it is necessary background for explaining the difference between stroking a selection and stroking a path.

When GIMP strokes a selection, what it actually is stroking is the "marching ants" outline of the selection (what some other image editors call a "marquee"). These marching ants run along the pixels where the selection transitions from below 50% to above 50% and, being the actual coordinates of the pixel, they are always integer values with no fractional components (zoom in to an elliptical selection and note the "stair-stepping" of the marching ants). While a brush stroke from one point on the marching ants to the next may include interpolated points containing fractional components, the end points of that stroke will always fall exactly on a pixel with integer coordinates (because they are on the marching ants).

When stroking a path, there is no restriction of the points on the path being integer values (zoom in while an elliptical path is shown and you will see that it does not follow the shape of the pixels like the marching ants do). This is why stroking a path renders the shape more accurately than stroking a selection, because the painting of the strokes is done with sub-pixel accuracy of all points along the stroke.

Re: Scaling paths?

Thu Oct 20, 2011 5:46 pm

I think i get it.The selection will round out to the next value then?
If you want 2 pixels selected it selects 2 pixels EXACTLY.
If you want 2.3 pixels selected it selects 2 pixels EXACTLY.
If you want 2.5 pixels selected it selects 3 pixels EXACTLY.

Why can't it select transparent pixels?After all they are there.Half or less alpha and the rest solid.
If it could do that you would pretty much have the same effect as the new foreground select tool right?

Re: Scaling paths?

Thu Oct 20, 2011 6:13 pm

Some important information for me to play with and figure out! Thank you all!

Re: Scaling paths?

Thu Oct 20, 2011 6:32 pm

Rod wrote:I think i get it.The selection will round out to the next value then?
If you want 2 pixels selected it selects 2 pixels EXACTLY.
If you want 2.3 pixels selected it selects 2 pixels EXACTLY.
If you want 2.5 pixels selected it selects 3 pixels EXACTLY.

Why can't it select transparent pixels?After all they are there.Half or less alpha and the rest solid.
If it could do that you would pretty much have the same effect as the new foreground select tool right?
Selection isn't interested by transparency but by selection :). But if you have partially selected pixels, since it has to translate an area (of things more or less selected) into a line, it takes the most obvious one, the outline of areas where selection > 127 which also happens to be the marching ants line, so there is no surprise for the user.

Moreover, if we can compute the value of a pixel given its distance to a line, the reverse may not be true, a "dark" pixel can be dark because its close to a single line, or because it's a bit farther from two different lines.

Re: Scaling paths?

Thu Oct 20, 2011 6:36 pm

Thanks Ofnuts. :)

Re: Scaling paths?

Thu Oct 20, 2011 11:41 pm

Thanks to everyone for all the detailed technical info on selection -vs- path.

Are there any procedures available to fill to path, something equivalent to fill to selection?

Re: Scaling paths?

Fri Oct 21, 2011 12:21 am

GnuTux wrote:Are there any procedures available to fill to path, something equivalent to fill to selection?

To my knowledge, there are none that are currently available to the user or exposed by the Procedural DataBase. Path filling is obviously performed when fonts are rendered, but this I believe is handled by the Pango and Cairo libraries.

GEGL provides a path filling operation, but it has not yet been made available to the user or the PDB. There also has been some work done on implementing "vector layers" in GIMP but I am not sure what the status of that project is. One of the concepts of vector layers is that every path has an associated fill color (or pattern), which may or may not be rendered.

As far as I know, filling a path is currently best handled by a manual process involving filling the selection and stroking the path. This also demands some degree of user analysis of the situation because these two operations may overlap when you don't want them to, or not overlap when you do.

Re: Scaling paths?

Fri Oct 21, 2011 1:12 am

Hopefully, we will see a "fill to path" procedure in the not to distant future. It seems another deficiency using "fill to selection/stroke to path" would be when the aim was to fill with a pattern or gradient, although using that approach might make for some interesting effects. :hehe

Re: Scaling paths?

Fri Oct 21, 2011 2:52 am

GnuTux wrote:Hopefully, we will see a "fill to path" procedure in the not to distant future. It seems another deficiency using "fill to selection/stroke to path" would be when the aim was to fill with a pattern or gradient, although using that approach might make for some interesting effects. :hehe


A fill to path option would be true vector objects then wouldn't it?
You would be in path/vector mode, so it would have to create the math for the fill right?

Could this be possible with a SVG gradient?Even if the gradient was 0% = 000000 100% = 000000.
(2 points on the gradient line)... this would fill all points in between with black or a solid color.You could also do it with real gradient fill (SVG), as Gimp already can handle SVG gradients.
Post a reply