使用 Imagemagick Convert 调整图像大小

gol*_*ean 2 image-manipulation imagemagick

我有一张尺寸为 1280x720 的 YUV420 图像。我正在尝试使用以下命令行选项使用 Convert (Imagemagick) 将其大小调整为 720x576。但生成的输出文件似乎不是正确调整大小的 YUV420 图像(我希望调整大小的输出也采用 YUV420 格式):

convert -size 1280x720 -depth 8 -sampling-factor 2x2  test_1280x720_yuv420.yuv  -filter lanczos -resize 720x576 -depth 8 -sampling-factor 2x2  720x576_yuv420.yuv //Here the output file size is not what it should be of a 720x576 YUV420 file which is 720x576x1.5 bytes. 
Run Code Online (Sandbox Code Playgroud)

Qiestion:那么这个输出文件的格式是什么?

还尝试了 -sample 选项,但结果相同。输出文件大小不正确。我什至尝试显示生成的调整大小的文件,但它肯定不是 YUV420 文件,因为根本无法正确查看它。

convert -size 1280x720 -depth 8 -sampling-factor 2x2  test_1280x720_yuv420.yuv   -sample 720x576 -depth 8 -sampling-factor 2x2  720x576_yuv420.yuv
Run Code Online (Sandbox Code Playgroud)

问题:convert 能够完成我想要完成的事情吗?如果是,有哪些选择?

问题:还有其他工具(免费软件、共享软件)可以帮助我将 YUV 文件(不同格式的 YUV420、YUV444)大小调整为 YUV 格式输出文件吗?

Far*_*ona 6

尝试忽略宽高比!

忽略纵横比('!'标志)如果您愿意,可以强制“-resize”忽略纵横比并扭曲图像,以便它始终生成与指定大小完全相同的图像。这是通过添加字符“!”来完成的 到尺寸。不幸的是,这个字符有时也被各种 UNIX 命令行 shell 用于特殊目的。因此,您可能必须以某种方式转义该角色才能保留它。

例子:

convert image.gif    -resize 64x64\!  resized_image.gif //Resized Image with ignore ratio option
Run Code Online (Sandbox Code Playgroud)