Skip to content

Commit

Permalink
Allow Image CDN to Proxy HEIC / HEIF Images (#33494)
Browse files Browse the repository at this point in the history
* Allow Image CDN to Proxy HEIC / HEIF Images

The backend `Photon_OpenCV` extension actually does build in HEIC support using the following libraries:

```
libheif-decoder.cpp
libheif-decoder.h
libheif-encoder.cpp
libheif-encoder.h
```

What's more it's even allowed by `photon/index.php` because while the `$allowed_types` is currently set as:

```
49	$allowed_types = apply_filters( 'allowed_types', array(
50	        'gif',
51	        'jpg',
52	        'jpeg',
53	        'png',
54	) );
```

`libheif` returns `jpeg` as the type for HEIC images:

```
$ wp shell
wp> $i = new Photon_OpenCV();
=> object(Photon_OpenCV)#4849 (0) {
}
wp> $i->readimageblob( file_get_contents( 'img.heic' ) );
=> NULL
wp> $i->getimageformat()
=> string(4) "jpeg"
```

So all we need to do is to allow `heic` extensions to be passed through Photon. In fact we can test this right now and see that it works as expected:
- HEIC: https://xiao.blog/sample.heic
- JPEG: https://i0.wp.com/xiao.blog/sample.heic?w=600

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/6482973632
  • Loading branch information
coder-karen authored and matticbot committed Oct 11, 2023
1 parent 704e3ee commit 1279b08
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 1279b08

Please sign in to comment.