API / Minn\Media / AvifInfo

AvifInfo final class

Minn\Media\AvifInfo · public/minn/src/Minn/Media/AvifInfo.php · 142 lines

An AVIF file's primary image as wp_get_avif_info reports it (probe media-tags): width and height from its spatial-extent property, bit depth and channel count from its pixel-information property. The file is an ISO base media file: an ftyp box naming the avif or avis brand, then a meta box whose primary item (pitm) is tied to its properties (ipco) by the association table (ipma). Anything else, or a file it cannot follow, is unknown in every field.

Constants and properties

privateUNKNOWN = array ( 'width' => false, 'height' => false, 'bit_depth' => false, 'num_channels' => false, )

Public

staticread(string $bytes): array#

The primary image's size, bit depth and channels from a file's first bytes.

@return array{width: int|false, height: int|false, bit_depth: int|false, num_channels: int|false}

Internals 5

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateisAvif(string $bytes, array $ftyp): bool#

Whether the ftyp box names the avif or avis brand, as its major brand or a compatible one.

privateprimaryItem(string $bytes, array $pitm): ?int#

The primary item's id from a pitm box: 16 bits in version 0, 32 after.

privateassociations(string $bytes, array $ipma, int $item): array#

The 1-based property indices the ipma box ties to one item.

$ipmaarray{0: int, 1: int}the box's content span
@return list<int>
privateboxes(string $bytes, int $from, int $to): array#

The boxes between two offsets by type, each as its content span (after the header). A box of size 1 carries a 64-bit size; size 0 runs to the end.

@return array<string, list<array{0: int, 1: int}>>
privateordered(string $bytes, int $from, int $to): array#

The boxes between two offsets in file order: type, content start, end.

@return list<array{0: string, 1: int, 2: int}>