What is the api way not pdb - 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) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: What is the api way not pdb (/Thread-What-is-the-api-way-not-pdb) Pages:
1
2
|
What is the api way not pdb - trandoductin - 11-11-2024 to get bounds or check to see if there is a selection present? as pdb. is slow for me when i do repeated operations. I tried looking at the api documentation but I don't know the syntax to call gimp_selection_is_empty? image.selection.width is always width of image it's so weird. I need this in order to speed up this knitted look 2.10 plugin RE: What is the api way not pdb - PixLab - 11-11-2024 Um... I'm a bit disoriented... are you @trandoductin AKA Tin > https://www.gimp-forum.net/User-trandoductin ? RE: What is the api way not pdb - trandoductin - 11-11-2024 (11-11-2024, 12:34 PM)PixLab Wrote: Um... I'm a bit disoriented... are you @trandoductin AKA Tin > https://www.gimp-forum.net/User-trandoductin ? Yeah I lost access to my email a while back so created this ttt account you got my hopes up with the api way since there was a reply hahah I tried uploading an avatar but for some reason it's not showing RE: What is the api way not pdb - Ofnuts - 11-11-2024 Can't think of a better way than is_empty = pdb.gimp_selection_is_empty(image) or non_empty, x1, y1, x2, y2 = pdb.gimp_selection_bounds(image) but both should be quick. You would use that only once anyway, if you know what your plugin code is doing with the selection. Looking at your plugin, a layer with the knit pattern over the original image blurred with Filter > Blur > Pixellize of adequate size would do the trick (yes, pixellize is the average and not the median...). And if you take the pattern size (width, height, bpp = pdb.gimp_pattern_get_info(name)you can do a plugin that auto-adapts to the pattern used (just pixellize to that size). RE: What is the api way not pdb - trandoductin - 11-11-2024 what? are you saying I can pixellize and having use a pattern shape that isn't rectangular? I know my pattern is rectangular but the way I color it is a V shape kind of. I am super curious now Currently I make selection for every V-shape on the image and then use average color to color the V-shape (not rectangle). aha used Gravatar to show my avatar now haha RE: What is the api way not pdb - trandoductin - 11-11-2024 I thought if pixelize can't do shape then i can at least use it to approximate colors and dodge using a bunch of repeated histogram calls. So now my code is 10% faster because i use get_pixel to get the pixelized color. RE: What is the api way not pdb - Ofnuts - 11-11-2024 (11-11-2024, 04:37 PM)ttt Wrote: I thought if pixelize can't do shape then i can at least use it to approximate colors and dodge using a bunch of repeated histogram calls. You can add a layer mask and fill it with the V-shape pattern. RE: What is the api way not pdb - trandoductin - 11-11-2024 (11-11-2024, 04:54 PM)Ofnuts Wrote:(11-11-2024, 04:37 PM)ttt Wrote: I thought if pixelize can't do shape then i can at least use it to approximate colors and dodge using a bunch of repeated histogram calls. Not sure what you mean because the V-shapes are all touching each other to fill the image. RE: What is the api way not pdb - Ofnuts - 11-11-2024 (11-11-2024, 06:10 PM)trandoductin Wrote:(11-11-2024, 04:54 PM)Ofnuts Wrote:(11-11-2024, 04:37 PM)ttt Wrote: I thought if pixelize can't do shape then i can at least use it to approximate colors and dodge using a bunch of repeated histogram calls. get_pixel() is a major performance problem. Other way: Create the selection shape only once, then shift the selection mask: channel = pdb.gimp_selection_save(image) # done once for whatever_loop: pdb.gimp_selection_none(image) pdb.gimp_drawable_offset(channel, True, OFFSET_WRAP_AROUND, 100,200) pdb.gimp_image_select_item(image,CHANNEL_OP_REPLACE,channel) # do whatever with new selection RE: What is the api way not pdb - trandoductin - 11-12-2024 I tried this but it seemed slower than doing my new selects everytime. worth a shot. I even tried saving as brush so i don't select and the brush but it wasn't any faster. I timed the get pixel and it was only 1.8 seconds out of 18 seconds. |