What is mask_bounds if the selection contains inner holes? - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +--- Thread: What is mask_bounds if the selection contains inner holes? (/Thread-What-is-mask-bounds-if-the-selection-contains-inner-holes) |
What is mask_bounds if the selection contains inner holes? - mavavilj - 08-22-2017 What is mask_bounds if the selection contains inner holes? Such as in: Or is there some other way to get the bounds? RE: What is mask_bounds if the selection contains inner holes? - Ofnuts - 08-22-2017 Code: non_empty, x1, y1, x2, y2 = pdb.gimp_selection_bounds(image) AFAIK this returns the smallest rectangle that contains all selected pixels. So that would be your outer rectangle. RE: What is mask_bounds if the selection contains inner holes? - mavavilj - 08-22-2017 So I can't get the inner bounds from anywhere, even though they're visible? RE: What is mask_bounds if the selection contains inner holes? - Ofnuts - 08-22-2017 You can: Code: pdb.plug_in_sel2path(image,None) This creates a vector/path with one stroke per rectangle. Each stroke appears to be 4 "triplets" (24 coordinates: 4 corners times 3 points(*) times 2 coordinates). The difficulty may be to figure out the inner ones from the outer ones (ie, which are "holes"). But if you have only one outer one, the rest being holes, this isn't too hard. See here for an introductions to paths if needed. See there for a bunch of scripts that deal with path, in particular the "pathSummary" function in ofn-path-edits. (*) since lines from the corners are straight lines, the "tangent handles" have the same coordinates as the anchors. See here for an introductions to paths if needed. See there for a bunch of scripts that deal with path, in particular the "summary" function in ofn-path-edits. |