nery89 Posted August 26, 2019 Share Posted August 26, 2019 (edited) I cannot find a plugin or command to resize the image surface to the closest rectangle around the "solid" image. For example, if i draw a small circle in the middle of the canvas, I would like to be able to crop it without going to select tool, adjusting etc. anybody can help? thank you!!! Edited August 26, 2019 by nery89 Quote Link to comment Share on other sites More sharing options...
nery89 Posted August 26, 2019 Author Share Posted August 26, 2019 (edited) no-no-no, i need to CROP (thank you, i just edited the post title) the transparent area to save the most space i can. for clarity sake i upload an example: imagine i have the BEFORE image, which is a small body in a transparent big background. what the function / plugin etc, should accomplish is cropping the image to get the AFTER image. AFTER image fill all the rectangle so there is at least 1 pixel non-transparet on each edge. sorry if i didn't explain very well, english is not my native language! thank you all! P.S. - the resul can be achived with this commands: magick wand -> select external transparent zone with 0% tolerance -> ctrl+i (invert selection) -> crop Edited August 26, 2019 by nery89 Quote Link to comment Share on other sites More sharing options...
Eli Posted August 26, 2019 Share Posted August 26, 2019 (edited) I think there is a plugin made by @MJW that does that but I can not find it. Edit : Object Pruner or perhaps Unselected Rectangle Keeper. Edited August 26, 2019 by Eli Quote Link to comment Share on other sites More sharing options...
MJW Posted August 26, 2019 Share Posted August 26, 2019 3 hours ago, Eli said: I think there is a plugin made by @MJW that does that but I can not find it. Edit : Object Pruner or perhaps Unselected Rectangle Keeper. You may be thinking of the awkwardly-named Unselected Rectangle Keeper. It's intended to help crop colored images on a flat-colored background. Unfortunately, I don' think it helps for this request. I think @nery89's P.S. comment is really the best solution at this time. The original request, as I understand it, isn't possible for a plugin, since plugins can't change the size of the canvas. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted August 26, 2019 Share Posted August 26, 2019 5 hours ago, nery89 said: P.S. - the resul can be achived with this commands: magick wand -> select external transparent zone with 0% tolerance -> ctrl+i (invert selection) -> crop You have already found the best way to do this. 1 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
nery89 Posted August 27, 2019 Author Share Posted August 27, 2019 14 hours ago, BoltBait said: You have already found the best way to do this. Ok, I saw the "Unselected Rectangle Keeper" which is kind of what I seek. with some edit to the code... maybe... can anyone point me to a tutorial on how to build a plugin so i can do what i need and maybe publish it afterward? Quote Link to comment Share on other sites More sharing options...
BoltBait Posted August 27, 2019 Share Posted August 27, 2019 If you want to learn how to create plugins, read these tutorials: https://forums.getpaint.net/topic/109990-how-to-write-an-effect-plugin-tutorialsresources/ Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
MJW Posted August 27, 2019 Share Posted August 27, 2019 I added a copy of the source code to my head post in "Unselected Rectangle Keeper" so nery89 can see how simple the code is to do what it does. It would be simpler, still, if I wrote it today. All the "firstTime" code could be done in CodeLab's PreRender, without the firstTime flag or the locks, like this: void PreRender(Surface src, Surface dst) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); Rectangle selection = selectionRegion.GetBoundsInt(); int l = int.MaxValue, r = -1, t = int.MaxValue, b = -1; for (int y = selection.Top; y < selection.Bottom; y++) { for (int x = selection.Left; x < selection.Right; x++) { if (!selectionRegion.IsVisible(x, y)) { if (x < l) l = x; if (x > r) r = x; if (t == int.MaxValue) t = y; b = y; } } } right = r; left = l; top = t; bottom = b; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.