Post Reply 

Cropping a polygon

Sep 9, 2011, 00:21
Post: #1
Cropping a polygon
I'm trying to crop a rectangle that is slightly off square, so the cropping rectangle is either clipping part of the image or not enough of the empty space. Is there a way to clip a non-rectangular area?

The images are actually parts of a map as a specific projection, and need to be clipped non-rectanguraly so they match up.

I've tried HELP and 'Google'oogling it, but no luck.

Thanks.
Find all posts by this user
Quote this message in a reply
Sep 9, 2011, 07:46 (This post was last modified: Sep 9, 2011 15:19 by ofnuts.)
Post: #2
RE: Cropping a polygon
All images (and layers, in Gimp) are rectangular. Those that don't look so are really rectangular but with transparent pixels.

To keep a polygon from an image:
- use the Path editor tool to define a polygonal closed path
- in the Path list, right click on the Path, and "Path to selection" (this will select the inside of the polygon)
- Select/Invert (to select the outside)
- make sure the layer has an alpha channel (Layer/Transparency/Add alpha channel)
- Delete (deletes the outside of the polygon: the layer becomes transparent outside the polygon)
- Layer/Autocrop layer (to reduce the layer to the smallest rectangle that fits)

If you need to align various maps, before doing the cropping, you can use this script:

http://registry.gimp.org/node/18961

Basically you define a path with 4 points, 2 above reference points on one layer, and two above reference points on the other layer, and it scales/rotates/translates in one operation the second layer so that the indicated points are exactly over the reference points. Not only is this much faster and accurate that the manual method, but since it's done in one transform there is little image degradation.

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Sep 9, 2011, 14:42
Post: #3
RE: Cropping a polygon
Thank You OFNUTS, I'll give it a try.
Find all posts by this user
Quote this message in a reply
Sep 20, 2011, 02:06
Post: #4
RE: Cropping a polygon
Hi OFNUTS...

Thanks recently for your assistance with my problems---yet again!!! I finished all 5 photos and I am waiting for clients response....

If I can add my 2 cents here, could not this user simply use the scissor tool as you had instructed me, on my difficult crop? It's just that it seemed very easy to do, compared with the 'path' thing.....

Only an observation---- you are the expert here...

Here were your instructions to me..:

- load picture
- make sure I can make the layer transparent: "Layer/Transparency/Add alpha channel"
- define clip path with scissors
- [Enter] to get the marching ants (this selects the player)
- "Select/Invert" to select the rest of the image
- [Delete] that leaves only the player and makes the rest transparent (which is a lot faster than doing a copy/paste to a new layer )

Then, all I did is 'save copy as"...named it....and voila!!! my crop was complete!!!

Ray
Miami Beach
Find all posts by this user
Quote this message in a reply
Sep 20, 2011, 02:08
Post: #5
RE: Cropping a polygon
Well, lol, on second thought, they BOTH look easy...

Ray
Find all posts by this user
Quote this message in a reply
Sep 20, 2011, 06:31 (This post was last modified: Sep 20, 2011 06:52 by ofnuts.)
Post: #6
RE: Cropping a polygon
(Sep 20, 2011 02:06)miamisunray Wrote:  Hi OFNUTS...

Thanks recently for your assistance with my problems---yet again!!! I finished all 5 photos and I am waiting for clients response....

If I can add my 2 cents here, could not this user simply use the scissor tool as you had instructed me, on my difficult crop? It's just that it seemed very easy to do, compared with the 'path' thing.....

Only an observation---- you are the expert here...

Here were your instructions to me..:

- load picture
- make sure I can make the layer transparent: "Layer/Transparency/Add alpha channel"
- define clip path with scissors
- [Enter] to get the marching ants (this selects the player)
- "Select/Invert" to select the rest of the image
- [Delete] that leaves only the player and makes the rest transparent (which is a lot faster than doing a copy/paste to a new layer )

Then, all I did is 'save copy as"...named it....and voila!!! my crop was complete!!!

Ray
Miami Beach

Well, if you want to crop a polygon in the general case, the "Intelligent scissors" are too intelligent and don't produce straight lines in some cases, for instance on a uniform background.

However, now that you make me reconsider this, there is a simpler solution than paths: the Lasso tool. You can use the Lasso to "draw" a selection as with a pencil, but you can also click successive points and it will make a polygon. But you have to be very careful where you click, you can't adjust the selection by dragging the summits as you could do with the Path tool. Using guides or the grid may help.

I'm not "the expert". I just like to explain things Smile

Edit: one advantage of Path for polygons is that there are scripts to generate regular polygons, see for instance: http://registry.gimp.org/node/59

Now answering your questions on
https://Gimp-Forum.net
Visit this user's website Find all posts by this user
Quote this message in a reply
Sep 20, 2011, 14:46
Post: #7
RE: Cropping a polygon
Thanks to both of you. I'll try all three methods to see which one works best for me. Nothing like learning through trial & error, eh?

Cheers...
Find all posts by this user
Quote this message in a reply
Oct 18, 2012, 10:29
Post: #8
RE: Cropping a polygon
Thanks a lot OFNUTS, you solved my problem!

(Sep 20, 2011 06:31)ofnuts Wrote:  
(Sep 20, 2011 02:06)miamisunray Wrote:  Hi OFNUTS...

Thanks recently for your assistance with my problems---yet again!!! I finished all 5 photos and I am waiting for clients response....

If I can add my 2 cents here, could not this user simply use the scissor tool as you had instructed me, on my difficult crop? It's just that it seemed very easy to do, compared with the 'path' thing.....

Only an observation---- you are the expert here...

Here were your instructions to me..:

- load picture
- make sure I can make the layer transparent: "Layer/Transparency/Add alpha channel"
- define clip path with scissors
- [Enter] to get the marching ants (this selects the player)
- "Select/Invert" to select the rest of the image
- [Delete] that leaves only the player and makes the rest transparent (which is a lot faster than doing a copy/paste to a new layer )

Then, all I did is 'save copy as"...named it....and voila!!! my crop was complete!!!

Ray
Miami Beach

Well, if you want to crop a polygon in the general case, the "Intelligent scissors" are too intelligent and don't produce straight lines in some cases, for instance on a uniform background.

However, now that you make me reconsider this, there is a simpler solution than paths: the Lasso tool. You can use the Lasso to "draw" a selection as with a pencil, but you can also click successive points and it will make a polygon. But you have to be very careful where you click, you can't adjust the selection by dragging the summits as you could do with the Path tool. Using guides or the grid may help.

I'm not "the expert". I just like to explain things Smile

Edit: one advantage of Path for polygons is that there are scripts to generate regular polygons, see for instance: http://registry.gimp.org/node/59
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cropping but selecting stuff to discard, not keep. seanspotatobuisness 1 96 Jul 14, 2017 18:46
Last Post: ythgilb
  image cropping to a pre-selected size geomcd49 1 210 Oct 1, 2014 04:42
Last Post: fluffybunny2
  Multiple Resizing, Oval Cropping and Watermarking ermns 9 290 Sep 30, 2014 02:18
Last Post: ermns
  trouble cropping active layer bugsinherteeth 5 278 Sep 4, 2014 20:37
Last Post: fluffybunny2
  Cropping an image to one layer's boundaries arielCo 6 533 Jun 29, 2014 06:40
Last Post: arielCo

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS