[SOLVED] Is it possible to split an image based on border detection over a transparent background?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Rubonnek
Posts: 2
Joined: 2016-11-14T20:11:23-07:00
Authentication code: 1151

[SOLVED] Is it possible to split an image based on border detection over a transparent background?

Post by Rubonnek »

Say, for example, we have a triangle and a circle on the same file and on a transparent background. Like this:

Image

And after processing the image we get the circle in one file and the triangle in another. Like cropping but instead of specifying the tile size, the shapes get autodetected and extracted into separate files.

I'm aware something similar can be done with a script I found here, but the images I need to do this on have more than two colors.
Last edited by Rubonnek on 2016-11-15T06:46:25-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Is it possible to split an image based on border detection over a transparent background?

Post by snibgo »

Code: Select all

call %PICTBAT%rectSubimages Vyl7bO4.png out.png
This creates out-0.png and out-1.png, the required images.

For the rectSubimages Windows BAT script, see my "Subimage rectangles" page.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is it possible to split an image based on border detection over a transparent background?

Post by fmw42 »

See my script multicrop for unix-based systems
Rubonnek
Posts: 2
Joined: 2016-11-14T20:11:23-07:00
Authentication code: 1151

Re: Is it possible to split an image based on border detection over a transparent background?

Post by Rubonnek »

snibgo wrote:

Code: Select all

call %PICTBAT%rectSubimages Vyl7bO4.png out.png
This creates out-0.png and out-1.png, the required images.

For the rectSubimages Windows BAT script, see my "Subimage rectangles" page.
I don't currently use ImageMagick on Windows, but I'll definitely keep this in mind. Thanks a lot!
fmw42 wrote:See my script multicrop for unix-based systems
I used multicrop2 and it worked wonderfully. Thanks a lot!
Post Reply