图像文件格式与图像"编码器名称"?之间的关系是什么?

时间:2015-10-12 20:35:26

标签: python image encoding python-imaging-library

我正在使用Python Imaging Library将照片转换为字节数组。这可以通过

来完成
im = Image.open("hello.jpg")
myImageArray = im.tobytes()

从文档中,tobytes函数由

定义
def tobytes(self, encoder_name="raw", *args):
        """
        Return image as a bytes object

        :param encoder_name: What encoder to use.  The default is to
                             use the standard "raw" encoder.
        :param args: Extra arguments to the encoder.
        :rtype: A bytes object.
        """

this回答中,Jon Skeet说"为了将图像转换为字节数组,您必须指定图像格式"。 编码器是图像格式吗?

tobytes默认为raw时,这是否意味着它被编码为.raw并且需要被解码为.raw以便正确解释,或者它们是否意味着原始的其他内容?尝试将JPEG文件编码为位图字节数组(即

)是否是荒谬的
im = Image.open("hello.jpg")
myImageArray = im.tobytes('not jpg encoder')

0 个答案:

没有答案
相关问题