本文介绍了用imagemagick分割图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在透明背景上有许多较小的图像(不接触)组成的大图像。像spritesheet一样,但精灵的大小不一样,也没有在网格上布局。
I have a large image made up of lots of smaller images (not-touching) on a transparent background. Like a spritesheet, but the sprites aren't all the same size, nor are they laid out on a grid.
我可以使用ImageMagick将图像分割成更小的图像?
Can I use ImageMagick to split the image into smaller images?
所以,例如,这个:(其中#
=彩色像素)
So, for example, this: (where #
= colored pixel)
# ##
# #
# #
###
成为这些
#
#
##
#
#
#
###
推荐答案
您可以在一个命令中执行此操作并非常有效地执行此操作。例如,这个命令:
You can do this in one single command and do it very efficiently. For example, this command:
time convert \
very-very-large.png \
-quality 85 \
-write mpr:mpc:label \
+delete \
mpr:mpc:label -crop '3000x2001+0+491' -resize '170x116!>' -write pic1.png +delete \
mpr:mpc:label -crop '2981x2883+8+0' -resize '75x75!>' -write pic2.png +delete \
mpr:mpc:label -crop '1100x1983+0+0' -resize '160x160!>' -write pic3.png +delete \
mpr:mpc:label -crop '2000x2883+0+0' -resize '1024x960!>' -write pic4.png +delete \
mpr:mpc:label -crop '1000x2883+0+0' -resize '190x188!>' -write pic5.png +delete \
mpr:mpc:label -crop '3000x2000+0+0' -resize '2048x2047!>' -write pic6.png +delete \
mpr:mpc:label -crop '3000x2883+0+0' -resize '595x421!>' -write pic7.png +delete \
mpr:mpc:label -crop '3000x2883+0+0' -resize '3000x2883!>' -write pic8.png
将剪切并保存(以不同名称)8个不同的子图像来自大的。
will cut and save (under different names) 8 different sub-images from the large one.
这篇关于用imagemagick分割图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!