我正在玩这里的api:
https://github.com/mukulhase/WebWhatsAPI
这是非常基本的,并且能够收到消息,但是当收到图像时,我会得到一个非常神秘的字符串。
例如此图片:
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAARCABMAGQDASIAAhEBAxEB/8QAHQAAAQQDAQEAAAAAAAAAAAAABgQFBwgAAwkBAv/EADsQAAIBAwMCBAMECAUFAAAAAAECAwQFEQAGEiExBxMiQQgUUTJhcYEJFSNCocHR8BaCkbHhFzNScvH/xAAbAQACAwEBAQAAAAAAAAAAAAAEBQIDBgAHAf/EADERAAIBAwICBgkFAAAAAAAAAAECAAMEEQUhEjEGEyJBgZEUFTJCYXGh0eFRU2Kx8P/aAAwDAQACEQMRAD8AnGio3rJDFETzwMEDp1+unuo31ZvDWazbZulK810uEvm25o6YO6STs0TEFmVeIEMXIFk9Jckt9kfewqX5i7qrEAP6eo/LP8dKfH3Ymzq+ih3DvK5C326C3SUSyRKPNaVpFeNV/exkOW446e499Be1w1YW7cjPLejdki0fTPezjw2lH/G+03WHd15uF5qovnqmvlWUmtSok5J6SrmMlVIIYEDAz1xjGIqlSRpDl+eCep9/fRJ4i1e27cnyFBf6uop6WoZYFqccxGM9OntyJ6ff74zqPn3IYzmmlIB+mjetSmoR5rKSMwyseJ0JX9tPIgToAD20zXGeL/tQycuvXp20krL+KlGapnY/fj+OkMVwpZZOKuOOMjOQc/noG6rK+yD7xjb0ym7TcoYtIXA9TdB7Y+mtM8bPKCzAKcAD646/114lzo8PHI2G5EKeuMZ/sa3uAeJ7jvnQQ5wokYj1Z5JIIPNDEAkcgpwT9Pyzot2jfTYt02m9A+Y1BW09QyjDMzIUOV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1KMyOVaPk4O67w6+HahuCVcfxI1FxpP1pTxGGPZ9XTyfJGqp45pRIzMOSQPUSgFBy8kDAZwgHaP4gvFi20ktLS7hovImSWNoZbJQSxhZJqmZwqvCQoL11UfTjAlKjCgAA95q5LhO1fNHTxyVDvMyU8CQRKzHJCRxgIi9eiqAoGAAAMa+gEd8ieYBkz2nw9+HCoguNNW/E3WwVEdxigoqtdkVUkU1GaSOR5ZIPMDRsKh3hwJHP7Bm4lXVgjsdR4T7dvVXbLR4g7mgrKa8w09t3alrRKN6FvJD1D0HM1Eflk1DBlmaQhYgIgWYrEMA8sK6ZBJ69e/b+ulCMWdlJ/f4/w1YnEu4JlNRQeyRkS8e2fHXYO6/DpBvTdG3aXfFHRgQy0VhrkaqkWnQiGZwxilZpHcPUYiIMPRGVg2pR2JtO373giue0dy2fcM0UfKqjoHkEsDAAn9jOqSAEH0+k+46kHXOS2zSrUBQ5wev5gD+uj+wXi5USLJS1TRNFwKkY7hjjv/wCo07taRqUzwuQfjuPLY/WZjUdNt6x9gA/Db8fSdMqChrbbT/K1FOY5AxJWUFGX7iCNZqmVs+IjxtpbfT08XiTeSiRqB5kwkbt7swJP5nWa46Hcv2sr5n7RWKSJ2Qx2+An/2Q==
看起来像上面的字符串
我的尝试是将字符串转换为字节表示:
msg = message[u'message']
by = str.encode(msg)
之后,我会将其转换为numpy数组,以将其重塑为图像尺寸(例如480x368像素)。
然而,有两个主要问题:
将它转换为numpy数组时,它将被描述为dtype='|S4876'
,它不能转换为数字表示。那么如何从我呈现的块中恢复图像?在不知道图像尺寸的情况下是否可能?
将产生以下输出: