使用 imagemagick 分割图像

blu*_*ume 5 image-manipulation image imagemagick image-processing

我有一个大图像,由透明背景上的许多较小图像(不接触)组成。就像精灵表一样,但精灵的大小并不相同,也不是排列在网格上。

我可以使用 ImageMagick 将图像分割成更小的图像吗?

因此,例如:(其中#= 彩色像素)

  #   ##
  #   # 
    # # 
  ###   
Run Code Online (Sandbox Code Playgroud)

变成这些

#
#

##
#
#

  #
###
Run Code Online (Sandbox Code Playgroud)

Pau*_*tte 0

使用三个裁剪命令,每个部分一个:

convert mosaic -crop 1x2+0+0 part1
convert mosaic -crop 2x3+2+0 part2
convert mosaic -crop 3x2+0+2 part3
Run Code Online (Sandbox Code Playgroud)