【发布时间】:2019-11-18 20:17:13
【问题描述】:
如果我上传小分辨率较低的图像,我得到 aws rekognition invalid parameter 异常。
见下面的错误
https://rekognition.us-west-2.amazonaws.com` resulted in a `400 Bad Request` response: {"__type":"InvalidImageFormatException","Message":"Request has invalid image format"} InvalidImageFormatException (client): Request has invalid image format - {"__type":"InvalidImageFormatException","Message":"Request has invalid image format"}' GuzzleHttp\Exception\ClientException: Client error: `POST https://rekognition.us-west-2.amazonaws.com` resulted in a `400 Bad Request` response: {"__type":"InvalidImageFormatException","Message":"Request has invalid image format"} in /var/www/vhosts/harvest.io.farm/aws/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:111 Stack trace: #0 /var/www/vhosts/harvest.io.farm/aws/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(Guz in /var/www/vhosts/harvest.io.farm/aws/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php on line 192
我的代码是
$result = $recognizationClient->indexFaces([
'CollectionId' => getCollectionName( $txtCID ), // REQUIRED
'Image' => [ // REQUIRED
'S3Object' => [
'Bucket' => $bucket,
'Name' => $actual_image_name
],
],
]);
【问题讨论】:
-
异常似乎是 InvalidImageFormatException,而不是 InvalidParameterException。文档告诉您,这意味着“不支持提供的图像格式”。它实际上是一个有效的图像吗?它是什么类型的图像(jpeg、png 等)?
-
是的,实际上它是 png 或 jpeg,但我想我发现问题是由于图像的最小尺寸,如果我们上传模糊图像或小于 100kb 的图像,那么只会出现这个错误,否则它可以工作完美,谢谢 jarmod
-
图片的最小高度和宽度均为 80 像素。
标签: php amazon-web-services amazon-rekognition