Python:即时将位图转换为JPG
我正在使用Autopy从Ubuntu台式机中获取屏幕截图,并以JPEG发布到MQTT,因此我可以通过MQTT摄像机实体在家庭助理上查看。我的解决方案有效,但我想无需中间文件即时进行转换。
screen=autopy.bitmap.capture_screen()
screen.save("screenshot.jpeg")
with open("screenshot.jpeg", 'rb') as f:
filecontent = f.read()
byteArr = bytearray(filecontent)
client.publish(topic_screen, byteArr)
当我使用它来检测同一项目中的鼠标运动时,我希望使用Autopy进行捕获。
I am using autopy to take screenshots from my ubuntu desktop and publish to mqtt as a jpeg so I can view on home assistant via the mqtt camera entity. My solution works but I want to do the conversion on the fly without an intermediate file.
screen=autopy.bitmap.capture_screen()
screen.save("screenshot.jpeg")
with open("screenshot.jpeg", 'rb') as f:
filecontent = f.read()
byteArr = bytearray(filecontent)
client.publish(topic_screen, byteArr)
I would prefer to use autopy for the capture as I am using this to detect mouse movements in the same project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论