【问题标题】:Best way to load a Pillow Image object from binary data in Python?从 Python 中的二进制数据加载 Pillow Image 对象的最佳方法?
【发布时间】:2020-09-13 16:06:51
【问题描述】:

我有一个使用 Python 的 Pillow 库修改 PNG 文件的程序。我想知道如何将二进制数据从 PIL 的 Image 对象加载到 PNG 图像中。我通过网络接收 PNG 作为二进制数据(例如,数据看起来像 b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR...')。完成这项任务的最佳方法是什么?

【问题讨论】:

    标签: python numpy python-imaging-library png


    【解决方案1】:

    我建议从io 标准库包中将数据接收到BytesIO 对象中。然后,您可以将其视为用于 Pillow 的类似文件的对象。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-04
      • 1970-01-01
      相关资源
      最近更新 更多