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/6480951346
  • Loading branch information
xyu authored and matticbot committed Oct 11, 2023
1 parent 60399eb commit 96af6e6
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 82 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"automattic/jetpack-connection": "^1.58.1",
"automattic/jetpack-identity-crisis": "^0.10.6",
"automattic/jetpack-my-jetpack": "^3.8.1",
"automattic/jetpack-search": "^0.39.1",
"automattic/jetpack-search": "^0.39.2-alpha",
"automattic/jetpack-stats": "^0.6.5",
"automattic/jetpack-status": "^1.18.5",
"automattic/jetpack-sync": "^1.57.4",
Expand Down
8 changes: 8 additions & 0 deletions jetpack_vendor/automattic/jetpack-search/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.39.2-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

### Added
- Added HEIC (`*.heic`) to list of images types allowed to be passed through Photon during instant search

## [0.39.1] - 2023-10-10
### Changed
- Updated package dependencies. [#33428]
Expand Down Expand Up @@ -812,6 +819,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated package dependencies.
- Update PHPUnit configs to include just what needs coverage rather than include everything then try to exclude stuff that doesn't.

[0.39.2-alpha]: https://github.com/Automattic/jetpack-search/compare/v0.39.1...v0.39.2-alpha
[0.39.1]: https://github.com/Automattic/jetpack-search/compare/v0.39.0...v0.39.1
[0.39.0]: https://github.com/Automattic/jetpack-search/compare/v0.38.8...v0.39.0
[0.38.8]: https://github.com/Automattic/jetpack-search/compare/v0.38.7...v0.38.8
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-block-editor', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-viewport'), 'version' => '10b3dd91ac891b56f5e6');
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-block-editor', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives', 'wp-url', 'wp-viewport'), 'version' => '378ccdaf497dab1e5669');

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-i18n', 'wp-jp-i18n-loader', 'wp-polyfill', 'wp-url'), 'version' => '0aa4f53ecbe8911b5307');
<?php return array('dependencies' => array('wp-i18n', 'wp-jp-i18n-loader', 'wp-polyfill', 'wp-url'), 'version' => 'b36b17c4696210868182');

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Search package general information
*/
class Package {
const VERSION = '0.39.1';
const VERSION = '0.39.2-alpha';
const SLUG = 'search';

/**
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/i18n-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
),
'jetpack-search-pkg' => array(
'path' => 'jetpack_vendor/automattic/jetpack-search',
'ver' => '0.39.1',
'ver' => '0.39.2-alpha1697018421',
),
'jetpack-stats' => array(
'path' => 'jetpack_vendor/automattic/jetpack-stats',
Expand Down
Loading

0 comments on commit 96af6e6

Please sign in to comment.