我正尝试通过POST请求将虚拟的2x2px二进制image / png文件发送到我创建的AWS API,然后将其中继到AWS Lambda服务。
Lambda服务具有python 3.6运行时,该运行时在event
对象中以event["body"]
的形式接收图像。
内容是图像的字符串表示形式:
"\ufffdPNG\r\n\u001a\n\u0000\u0000\u0000\rIHDR\u0000\u0000\u0000\u0002\u0000\u0000\u0000\u0002\b\u0002\u0000\u0000\u0000\ufffdԚs\u0000\u0000\u0000\tpHYs\u0000\u0000\u000b\u0013\u0000\u0000\u000b\u0013\u0001\u0000\ufffd\ufffd\u0018\u0000\u0000\u0006=iTXtXML:com.adobe.xmp\u0000\u0000\u0000\u0000\u0000<?xpacket begin=\"\ufeff\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?> <x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 5.6-c142 79.160924, 2017/07/13-01:06:39 \"> <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"> <rdf:Description rdf:about=\"\" xmlns:xmp=\"http://ns.adobe.com/xap/1.0/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:photoshop=\"http://ns.adobe.com/photoshop/1.0/\" xmlns:xmpMM=\"http://ns.adobe.com/xap/1.0/mm/\" xmlns:stEvt=\"http://ns.adobe.com/xap/1.0/sType/ResourceEvent#\" xmp:CreatorTool=\"Adobe Photoshop CC (Windows)\" xmp:CreateDate=\"2019-06-04T16:46:08+02:00\" xmp:ModifyDate=\"2019-06-04T17:32:54+02:00\" xmp:MetadataDate=\"2019-06-04T17:32:54+02:00\" dc:format=\"image/png\" photoshop:ColorMode=\"3\" photoshop:ICCProfile=\"sRGB IEC61966-2.1\" xmpMM:InstanceID=\"xmp.iid:65b3d116-9cf2-6840-bb1f-d198c1c93833\" xmpMM:DocumentID=\"adobe:docid:photoshop:1ce4432e-f100-6646-b53f-7597bec5246e\" xmpMM:OriginalDocumentID=\"xmp.did:5dbdc57c-49b9-864a-adc4-47d641b655f0\"> <xmpMM:History> <rdf:Seq> <rdf:li stEvt:action=\"created\" stEvt:instanceID=\"xmp.iid:5dbdc57c-49b9-864a-adc4-47d641b655f0\" stEvt:when=\"2019-06-04T16:46:08+02:00\" stEvt:softwareAgent=\"Adobe Photoshop CC (Windows)\"/> <rdf:li stEvt:action=\"converted\" stEvt:parameters=\"from image/bmp to image/png\"/> <rdf:li stEvt:action=\"saved\" stEvt:instanceID=\"xmp.iid:65b3d116-9cf2-6840-bb1f-d198c1c93833\" stEvt:when=\"2019-06-04T17:32:54+02:00\" stEvt:softwareAgent=\"Adobe Photoshop CC (Windows)\" stEvt:changed=\"/\"/> </rdf:Seq> </xmpMM:History> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end=\"r\"?>\ufffd\ufffd\u0007\u0000\u0000\u0000\u0014IDAT\b\u001dc\\>\ufffd\ufffd\u0011\b\ufffd\n\ufffd\ufffdy\ufffd\u0000\u001cq\u0003=0\u0015\u001b\ufffd\u0000\u0000\u0000\u0000IEND\ufffdB\ufffd"
我似乎无法使用PIL或numpy库处理字符串以产生Image对象或numpy数组。任何想法如何处理这种情况?