File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9090 env :
9191 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
9292
93+ - name : Enable HEIC support in ImageMagick
94+ run : |
95+ # The HEIC preview tests need ImageMagick to actually decode HEIC files.
96+ # GitHub-hosted runners register the HEIC coder (so the tests are not
97+ # skipped) but decoding fails because the libheif delegate is missing
98+ # and/or the coder is blocked by ImageMagick's security policy. Install
99+ # the delegate and allow the HEIC/HEIF/AVIF coders so decoding succeeds.
100+ sudo apt-get update
101+ sudo apt-get install -y --no-install-recommends libheif1 libheif-dev
102+ for policy in /etc/ImageMagick-{6,7}/policy.xml; do
103+ if [ -f "$policy" ]; then
104+ sudo sed -i -E 's/rights="none" pattern="(HEIC|HEIF|AVIF)"/rights="read|write" pattern="\1"/g' "$policy"
105+ fi
106+ done
107+
93108 - name : Set up dependencies
94109 run : composer i
95110
Original file line number Diff line number Diff line change 66
77namespace Test \Preview ;
88
9+ use OC \Preview \HEIC ;
10+
911/**
1012 * Class BitmapTest
1113 *
@@ -17,14 +19,27 @@ class HEICTest extends Provider {
1719 protected function setUp (): void {
1820 if (!in_array ('HEIC ' , \Imagick::queryFormats ('HEI* ' ))) {
1921 $ this ->markTestSkipped ('ImageMagick is not HEIC aware. Skipping tests ' );
20- } else {
21- parent ::setUp ();
22+ }
23+
24+ $ fileName = 'testimage.heic ' ;
25+ $ sourcePath = \OC ::$ SERVERROOT . '/tests/data/ ' . $ fileName ;
2226
23- $ fileName = 'testimage.heic ' ;
24- $ this ->imgPath = $ this ->prepareTestFile ($ fileName , \OC ::$ SERVERROOT . '/tests/data/ ' . $ fileName );
25- $ this ->width = 1680 ;
26- $ this ->height = 1050 ;
27- $ this ->provider = new \OC \Preview \HEIC ;
27+ // queryFormats() only reports that the HEIC coder is registered, not that
28+ // ImageMagick can actually decode a HEIC file: the libheif delegate may be
29+ // missing or the coder may be disabled by ImageMagick's policy.xml. In that
30+ // case decoding throws, the provider returns null and the tests fail instead
31+ // of being skipped. Verify a real decode before running the tests.
32+ try {
33+ (new \Imagick ())->readImage ($ sourcePath . '[0] ' );
34+ } catch (\ImagickException $ e ) {
35+ $ this ->markTestSkipped ('ImageMagick cannot decode HEIC in this environment: ' . $ e ->getMessage () . '. Skipping tests ' );
2836 }
37+
38+ parent ::setUp ();
39+
40+ $ this ->imgPath = $ this ->prepareTestFile ($ fileName , $ sourcePath );
41+ $ this ->width = 1680 ;
42+ $ this ->height = 1050 ;
43+ $ this ->provider = new HEIC ;
2944 }
3045}
You can’t perform that action at this time.
0 commit comments