Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在AWS Lambda上使用python中的pillow包保存图像时出错/内容类型错误_Python_Image Processing_Aws Lambda_Python Imaging Library_Mime Types - Fatal编程技术网

在AWS Lambda上使用python中的pillow包保存图像时出错/内容类型错误

在AWS Lambda上使用python中的pillow包保存图像时出错/内容类型错误,python,image-processing,aws-lambda,python-imaging-library,mime-types,Python,Image Processing,Aws Lambda,Python Imaging Library,Mime Types,我正在尝试使用python的枕头包生成三维图像。我面临的问题是“内容类型自动转换为二进制/八位字节流,但我原来的图像内容类型是图像/jpeg” 下面是我用来生成缩略图的代码 def resize_image(image_path, resized_path, thumbnail_size): with Image.open(image_path) as image: image.thumbnail((thumbnail_size["x"], thumbnail_size

我正在尝试使用python的枕头包生成三维图像。我面临的问题是“内容类型自动转换为二进制/八位字节流,但我原来的图像内容类型是图像/jpeg

下面是我用来生成缩略图的代码

 def resize_image(image_path, resized_path, thumbnail_size):
    with Image.open(image_path) as image:
        image.thumbnail((thumbnail_size["x"], thumbnail_size["y"]))
        image.save(resized_path,"JPEG",progressive=True)

最终找到了解决方案,问题是在将文件上载到s3时,您需要明确指定内容类型

s3_client.upload_file(upload_path, '{}'.format(bucket),
                      f'{filename}',ExtraArgs={'ContentType': '{}'.format(mimeType),'Metadata':{}})