How to split image into uneven parts?

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
Alex Jr
Posts: 3
Joined: 2017-04-21T14:04:06-07:00
Authentication code: 1151

How to split image into uneven parts?

Post by Alex Jr »

Hi everyone, I installed ImageMagick for Terminal on Mac and I am wondering how I can split my image into uneven pieces, and create a new file for each piece?

Image

No, I am not going to release this copyrighted image in my game, its just for experimentation.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to split image into uneven parts?

Post by fmw42 »

Please always provide your IM version and platform, since syntax and scripting may differ.

How does one know where to split these, since especially some overlap horizontally?

If there is not a clean separation, then you likely will have to do that manually using the -crop operator. See http://www.imagemagick.org/Usage/crop/#crop
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to split image into uneven parts?

Post by snibgo »

Code: Select all

convert 83596.png -alpha extract -scale x1! -fill White +opaque Black a.png
This is black where we can cut, and white where we can't. However, it misses the right-most cut point because of the "Sprites ripped by..." text.
snibgo's IM pages: im.snibgo.com
Alex Jr
Posts: 3
Joined: 2017-04-21T14:04:06-07:00
Authentication code: 1151

Re: How to split image into uneven parts?

Post by Alex Jr »

IM Version @6.9.8-3_0+x11, Platform OS X El Capitan, 10.11.6
Alex Jr
Posts: 3
Joined: 2017-04-21T14:04:06-07:00
Authentication code: 1151

Re: How to split image into uneven parts?

Post by Alex Jr »

@snibgo, What's 83596.png and a.png supposed to represent?

This is my first time using ImageMagick.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to split image into uneven parts?

Post by fmw42 »

Alex Jr wrote: 2017-04-21T14:27:57-07:00 @snibgo, What's 83596.png and a.png supposed to represent?

This is my first time using ImageMagick.
The input and output images, respectively.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to split image into uneven parts?

Post by snibgo »

As Fred says. The file you uploaded has been renamed 83596.png by that website.

If you know the x-coordinates of your cut positions or the width of the pieces, you can just do a number of "-crop" operations. Five of the cut points can be found automatically (eg by my guillotine.bat script). If you crop off the "Sprites ripped by..." text, it finds them all.
snibgo's IM pages: im.snibgo.com
Post Reply