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