-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageData.php
48 lines (42 loc) · 1.23 KB
/
ImageData.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types=1);
namespace MoeMizrak\Rekognition\Data;
use MoeMizrak\Rekognition\Data\Contracts\RekognitionDataFormatInterface;
use Spatie\LaravelData\Data;
/**
* Provides the input image either as bytes or an S3 object.
* For more info: https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-rekognition-2016-06-27.html#shape-image
* Also check: https://docs.aws.amazon.com/rekognition/latest/dg/images-information.html
*
* @class ImageData
*/
final class ImageData extends Data implements RekognitionDataFormatInterface
{
public function __construct(
/*
* Blob of image bytes up to 5 MBs.
*
* @param string|resource|StreamInterface|null
*/
public mixed $bytes = null,
/*
* Identifies an S3 object as the image source.
*
* @param S3ObjectData|null
*/
public ?S3ObjectData $s3Object = null
) {}
/**
* @inheritDoc
*/
public function toRekognitionDataFormat(): array
{
return array_filter(
[
'Bytes' => $this->bytes,
'S3Object' => $this->s3Object?->toRekognitionDataFormat(),
],
fn ($value) => $value !== null
);
}
}