Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support AVIF and HEIC in Imagick driver #759

Merged
merged 3 commits into from
Sep 30, 2021

Conversation

ausi
Copy link
Contributor

@ausi ausi commented Feb 13, 2021

This adds support for AVIF and HEIC in the Imagick driver as suggested in #742 and #755.

This is still a work in progress. Saving files already works fine, but reading images files currently fails because imagemagick (incorrectly?) reports Imagick::COLORSPACE_YCBCR as the colorspace even though it is RGB. Just ignoring this doesn’t seem to work because the color profile doesn’t get interpreted correctly then (tested with an iPhone HEIC image).

This was referenced Feb 13, 2021
@ausi
Copy link
Contributor Author

ausi commented Feb 13, 2021

I was able to fix the colorspace issue by the suggested fix from @jleckie in #756. Now the color profile gets applied correctly and the colors stay the same with my test files.

@ausi
Copy link
Contributor Author

ausi commented Feb 13, 2021

The failing tests do not seem to be related to this pull request.

@laxity7
Copy link

laxity7 commented Sep 29, 2021

So what about this MR? Obviously, the solution is working, the problem is outside of this MR.

Can you accept it? Doesn't work with heic without it

@mlocati mlocati merged commit d8c64eb into php-imagine:develop Sep 30, 2021
@mlocati
Copy link
Collaborator

mlocati commented Oct 5, 2021

@ausi Do you have a working environment for imagick + HEIC?
I'm trying to fix the tests: they now use Docker images (built by https://github.com/php-imagine/docker-builder/blob/main/.github/workflows/create-images.yml and https://github.com/php-imagine/docker-builder/blob/main/docker/installer.sh)
In the imagick tests we have errors like this one:

Imagine\Test\Imagick\ImageTest::testSaveCompressionQuality with data set #5 ('heic', array(0), array(100))
Imagine\Exception\RuntimeException: Save operation failed

src/Imagick/Image.php:343
tests/tests/Image/AbstractImageTest.php:1031
tests/tests/Imagick/ImageTest.php:179

Caused by
ImagickException: no encode delegate for this image format `HEIC' @ error/constitute.c/WriteImage/1272

src/Imagick/Image.php:341
tests/tests/Image/AbstractImageTest.php:1031
tests/tests/Imagick/ImageTest.php:179

@ausi
Copy link
Contributor Author

ausi commented Oct 5, 2021

Using https://github.com/SoftCreatR/imei has worked for me.

The complete Dockerfile I used looks like this:

FROM php:7.4-cli
RUN apt-get update \
 && apt-get install -y wget libmagickwand-dev --no-install-recommends \
 && curl https://raw.githubusercontent.com/SoftCreatR/imei/main/imei.sh | bash

RUN pecl install imagick \
 && docker-php-ext-enable imagick \
 && docker-php-ext-install exif \
 && docker-php-ext-enable exif \
 && docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
 && docker-php-ext-install gd \
 && docker-php-ext-enable gd

@ausi
Copy link
Contributor Author

ausi commented Oct 5, 2021

@mlocati
Copy link
Collaborator

mlocati commented Oct 5, 2021

Nope: it's detected automatically: see https://github.com/php-imagine/docker-builder/runs/3806674769?check_suite_focus=true#step:11:1144

I'll try to see of installing some additional libraries fixes the issue (the script you linked above is very helpful)

@mlocati
Copy link
Collaborator

mlocati commented Oct 6, 2021

I understood what's missing: libheif uses libde265 to read heic files, and libx265 to write them: I only installed libde265

@mlocati
Copy link
Collaborator

mlocati commented Oct 6, 2021

@laxity7
Copy link

laxity7 commented Oct 6, 2021

When will the release be?
The master does not yet have these changes, but it is very necessary.

And thanks for being active

@mlocati
Copy link
Collaborator

mlocati commented Oct 6, 2021

Once all these issues will be fixed: https://github.com/php-imagine/Imagine/milestone/1

(Help wamted, I ran out of spare time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants