调整大小不符合分辨率规范
Resizing does not respect resolution specification
我有一张由 16x16 图像组成的 16x512 图像。我想将它们分开,将每个单独缩小到 16x8,然后将它们全部放回完整的 16x512。我有一个基本的想法,但我很难执行它。
使用 unix stackexchange, I split by file by using convert -crop 16x16 my_image.png crop-%d.png
, which yields 32 images (512 / 16 == 32). My next step was where trouble has started. From askubuntu, I found the command mogrify -resize 16x8 crop-*.png
, however this does not yield 16x8 images, but rather 8x8, which I do not want. Furthermore, this post on Whosebug 中的命令为我提供了合并这些图像的命令,即 convert crop-*.png -append my_image_cropped.png
,但它不会像我想要的那样产生 16x512,而是 8x256(8 到期以前的错误,但我仍然想要 512 的高度,而不是 256)。
我需要什么来实现我的目标?可以在 imgur.
上找到相关图片
编辑:这里有一些描述基本思想的图片
完整图片:
16x16 和 16x8 并排
最终的图像,基本上 16x8 将位于 16x16 区域(在底部,这是必不可少的),但不会完全填充它。
我不确定我明白你想做什么。但是,如果您调整 16x8 的大小,Imagemagick 将保持宽高比。如果你想强制它正好是 16x8 并且可以接受失真,那么使用 !旗帜。但是你然后说你想把 32 块放回 16x512 的形式,但是调整大小会使它变成 16x256,因为你有 32 个高度为 8 的图像。所以你必须再次调整大小。如果这真的是你想要的,这里是如何做到这一点。
创建用于测试的渐变图像:
convert -size 16x512 gradient: grad.png
进行处理:
convert grad.png -crop 16x16 -resize 16x8! -append -resize 16x512! newgrad.png
请注意,正确的 Imagemagick 语法首先读取输入。
加法:
根据您评论中的新信息,试试这个:
convert grad.png -crop 16x16 -resize 16x8 -gravity northwest -background none -extent 16x16 -append newgrad.png
根据需要更改背景颜色和所需的重力设置以进行定位。
我有一张由 16x16 图像组成的 16x512 图像。我想将它们分开,将每个单独缩小到 16x8,然后将它们全部放回完整的 16x512。我有一个基本的想法,但我很难执行它。
使用 unix stackexchange, I split by file by using convert -crop 16x16 my_image.png crop-%d.png
, which yields 32 images (512 / 16 == 32). My next step was where trouble has started. From askubuntu, I found the command mogrify -resize 16x8 crop-*.png
, however this does not yield 16x8 images, but rather 8x8, which I do not want. Furthermore, this post on Whosebug 中的命令为我提供了合并这些图像的命令,即 convert crop-*.png -append my_image_cropped.png
,但它不会像我想要的那样产生 16x512,而是 8x256(8 到期以前的错误,但我仍然想要 512 的高度,而不是 256)。
我需要什么来实现我的目标?可以在 imgur.
上找到相关图片编辑:这里有一些描述基本思想的图片
完整图片:
16x16 和 16x8 并排
最终的图像,基本上 16x8 将位于 16x16 区域(在底部,这是必不可少的),但不会完全填充它。
我不确定我明白你想做什么。但是,如果您调整 16x8 的大小,Imagemagick 将保持宽高比。如果你想强制它正好是 16x8 并且可以接受失真,那么使用 !旗帜。但是你然后说你想把 32 块放回 16x512 的形式,但是调整大小会使它变成 16x256,因为你有 32 个高度为 8 的图像。所以你必须再次调整大小。如果这真的是你想要的,这里是如何做到这一点。
创建用于测试的渐变图像:
convert -size 16x512 gradient: grad.png
进行处理:
convert grad.png -crop 16x16 -resize 16x8! -append -resize 16x512! newgrad.png
请注意,正确的 Imagemagick 语法首先读取输入。
加法:
根据您评论中的新信息,试试这个:
convert grad.png -crop 16x16 -resize 16x8 -gravity northwest -background none -extent 16x16 -append newgrad.png
根据需要更改背景颜色和所需的重力设置以进行定位。