[英]does wand support reading/writing webp images?
我有blob代表webp图像我希望能够使用Wand从blob创建图像,然后将其转换为jpeg。 这可能与Wand或任何其他python库。
Wand是imagemagick的包装器 - 通常,Wand支持的文件类型基于如何在相关系统上配置imagemagick。
例如,如果您使用自制软件在Mac上,则需要安装:
brew install imagemagick --with-webp
好吧,我无法用魔杖做到这一点。 我找到了另一个图书馆Pillow 。
我有一个java脚本代码从canvas获取视频帧并将webp imge从based64转换为二进制image并使用web socket将其发送到服务器上的服务器我构建映像并将其从webp转换为jpeg然后使用OpenCV处理jpeg图像。 这是一个示例代码
from PIL import Image
import StringIO
import numpy as np
import cv2
#webpimg is binary webp image received from the websocket
newImg = Image.open(StringIO.StringIO(webpimg)).convert("")
temp = StringIO.StringIO()
newImg.save(temp, "JPEG")
contents = temp.getvalue()
temp.close()
array = np.fromstring(contents, dtype=np.uint8)
jpegimg = cv2.imdecode(array, cv2.CV_LOAD_IMAGE_COLOR)
cv2.imwrite("imgCV.jpeg", img1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.