您可以使用 . 查看支持的格式集vips -l
。对于 8.10,它是:
$ vips -l | grep _target
VipsForeignSaveCsvTarget (csvsave_target), save image to csv (.csv), priority=0, mono
VipsForeignSaveMatrixTarget (matrixsave_target), save image to matrix (.mat), priority=0, mono
VipsForeignSavePpmTarget (ppmsave_target), save to ppm (.ppm, .pgm, .pbm, .pfm), priority=0, rgb
VipsForeignSaveRadTarget (radsave_target), save image to Radiance target (.hdr), priority=0, rgb
VipsForeignSavePngTarget (pngsave_target), save image to target as PNG (.png), priority=0, rgba
VipsForeignSaveJpegTarget (jpegsave_target), save image to jpeg target (.jpg, .jpeg, .jpe), priority=0, rgb-cmyk
VipsForeignSaveWebpTarget (webpsave_target), save image to webp target (.webp), priority=0, rgba-only
VipsForeignSaveHeifTarget (heifsave_target), save image in HEIF format (.heic, .heif, .avif), priority=0, rgba-only
.v
并且.raw
可能会在 8.11 中添加。.bmp
是由 imagemagick 而不是 libvips 编写的,可能无法成功。
另一种选择是使用 Python 接口pyvips之类的东西,而不是 CLI。例如:
import os
import pyvips
image = pyvips.Image.black(10, 10)
memory = image.write_to_memory()
os.write(1, memory)
将以二进制模式将原始字节(在本例中为 100 个零)写入标准输出。
要改用 BMP,您可以编写:
memory = image.magicksave_buffer(format="BMP")