gpt4 book ai didi

graphicsmagick - 如何使用 GraphicsMagick 裁剪到多个图像

转载 作者:行者123 更新时间:2023-12-04 06:42:39 25 4
gpt4 key购买 nike

根据GraphicsMagick man page我可以使用 -crop 从一个图像创建多个图块没有偏移:

If the x and y offsets are omitted, a set of tiles of the specified geometry, covering the entire input image, is generated. The rightmost tiles and the bottom tiles are smaller if the specified geometry extends beyond the dimensions of the input image.



所以我运行了以下命令(在 Linux 下):

gm convert -crop 256x256 input.png tile      # => a single file called tile
gm convert -crop 256x256 input.png tile.png # => a single file called tile.png

如何指定输出以便创建多个图像?

最佳答案

gm convert -crop 256x256 input.png +adjoin tile%04d.png

+毗邻 是关键。

来自 Files and Formats手册部分:

Single images are written with the filename you specify. However, multi-part images (e.g., a multi-page PostScript document with +adjoin specified) may be written with the scene number included as part of the filename. In order to include the scene number in the filename, it is necessary to include a printf-style %d format specification in the file name and use the +adjoin option. For example,

 image%02d.miff

writes files image00.miff, image01.miff, etc. Only a single specification is allowed within an output filename. If more than one specification is present, it will be ignored. It is best to embed the scene number in the base part of the file name, not in the extension, because the extension will not be a recognizeable image type.



adjoin部分:

Use +adjoin to force saving multiple frames to multiple numbered files. If +adjoin is used, then the output filename must include a printf style formatting specification for the numeric part of the filename. For example,

image%02d.miff

关于graphicsmagick - 如何使用 GraphicsMagick 裁剪到多个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25883738/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com