GIMP 2.10.12
In rare cases, you want to individually separate sprite animation materials and facial expression difference materials that are often seen in image materials such as Tsukuru. This time, I will introduce how to divide such a set image into a sword with GIMP.
The material for this time was borrowed from Pipoya Warehouse.
Depending on the tool you are trying to use the material for, you may want to check once ** whether you need to split the image file itself ** in the first place. For example, Unity originally supports such materials and can be treated as a split image in the image import settings. (This article etc. will be helpful.)
As a flow
You can make a grid-like guide by repeating the following and adding guides. However, it is troublesome to repeat it manually, so let's do it all at once using Python-Fu as described below **. (Explaned in the next item)
--Select "Image"-> "Guide"-> "New Guide" from the menu.
--Specify the direction and the position of the guide and press "OK".
--You can guide.
GIMP has a feature called Python-Fu that can be manipulated with Python scripts. (Convenient!)
--Select "Filter"-> "Python-Fu"-> "Console" from the menu.
--The Python console screen will open, so continue with the script. For what each line is doing, see the Library Reference Manual along with the sites and books that deal with Python courses. I think it's quick to get it.
Script example to execute
column = 6 #Number of columns you want to isolate
row = 12 #Number of lines you want to separate
image = gimp.image_list()[0]
step = image.width / column
x = step
while x < image.width:
pdb.gimp_image_add_vguide(image, x)
x = x + step
step = image.height / row
y = step
while y < image.height:
pdb.gimp_image_add_hguide(image, y)
y = y + step
――It's done.
--From the menu, select "Image"-> "Slice Using Guides".
--Divided according to the guide. You can see that each image is displayed above as a tab.
You can save one by one by selecting "File"-> "Export" from the menu, but it seems that there is no batch save, so Python-Fu is also useful here.
--Run the following script on the Python console screen. (The original image does not need to be saved, so close it first.)
Script example to execute
import os
path = "F:\\balloon" #Destination
count = 0
for image in gimp.image_list():
count += 1
file = os.path.join(path, str(count).zfill(2) + ".png ")
pdb.gimp_file_save(image, image.active_layer, file, "")
――It will be spit out to the specified folder more and more. I was able to divide it happily.
GIMP is famous for being free and highly functional, but I'm very happy to be able to write scripts in the popular Python. I wanted to be able to use it more.
Recommended Posts