docker-images-php icon indicating copy to clipboard operation
docker-images-php copied to clipboard

Support of HEIC / HEIF MimeType in IMagick

Open JapanDoudou67 opened this issue 4 years ago • 3 comments

Hello everyone ! First, thank for your work :)

I'm Using the thecodingmachine/php:7.4-v4-fpm image for a project on Symfony. I activate the ext-imagick extension in my composer.json and PHP_EXTENSION_IMAGICK in my docker-compose.

But my new Imagick() cannot read HEIC images from IPhone :(

I tried to apply this tuto on my current configuration :

https://eplt.medium.com/5-minutes-to-install-imagemagick-with-heic-support-on-ubuntu-18-04-digitalocean-fe2d09dcef1

Here is my DockerCompose :

php_web:
    build: docker/php
    tty: true
    links:
      - postgres
    volumes:
      - ".:/var/www/html"
    depends_on:
      - postgres
    environment:
      PHP_INI_POST_MAX_SIZE: 30M
      PHP_INI_UPLOAD_MAX_FILESIZE: 30M
      PHP_EXTENSION_IMAGICK: 1

Here is my DockerFile :

FROM thecodingmachine/php:7.4-v4-fpm

ENV PHP_EXTENSION_PDO_PGSQL=1
ENV PHP_EXTENSION_APCU=1
ENV PHP_EXTENSION_INTL=1
ENV PHP_EXTENSION_GD=1
ENV PHP_EXTENSION_REDIS=1
ENV PHP_EXTENSION_MYSQLI=0
ENV PHP_EXTENSION_PDO_MYSQL=0
ENV PHP_EXTENSION_XDEBUG=0
ENV PHP_INI_ERROR_REPORTING=0
ENV PHP_INI_MEMORY_LIMIT=256M
ENV PHP_INI_POST_MAX_SIZE: 30M
ENV PHP_INI_UPLOAD_MAX_FILESIZE: 30M
ENV TZ="Europe/Paris"

RUN sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list && \
    sudo apt-get update && \
    sudo apt-get install -y build-essential autoconf libtool git-core && \
    sudo apt-get build-dep -y imagemagick libmagickcore-dev libde265 libheif && \
    cd /usr/src/ && \
    sudo git clone https://github.com/strukturag/libde265.git && \
    sudo git clone https://github.com/strukturag/libheif.git && \
    cd libde265/ && \
    sudo ./autogen.sh && \
    sudo ./configure && \
    sudo make && \
    sudo make install && \
    cd /usr/src/libheif/ && \
    sudo ./autogen.sh && \
    sudo ./configure && \
    sudo make && \
    sudo make install && \
    cd /usr/src/ && \
    sudo wget https://www.imagemagick.org/download/ImageMagick.tar.gz && \
    sudo tar xf ImageMagick.tar.gz && \
    cd ImageMagick-7* && \
    sudo ./configure --with-heic=yes && \
    sudo make && \
    sudo make install && \
    sudo ldconfig

Expected Behavior

Converting a HEIC image to an other format

Current Behavior

The error that Symfony return is : "no decode delegate for this image format `HEIC' @ error/constitute.c/ReadImage/560" It actualy work if I ry to convert PNG files for sample.

Possible Solution

Support the last Imagick version 3.4.4 with HEIC support (feel free to see the link)

Steps to Reproduce (for bugs)

I'm on Symfony 4.2 with the VichUploader bundle to manage file upload

My code :

<?php

declare(strict_types=1);

namespace App\Manager;

use Symfony\Component\HttpFoundation\File\File;

class ImageConverter {
    /**
     * @param File $myImage
     * @param int $compressionQuality
     * @return string
     * @throws ImagickException
     */
    public static function convertHeicToJpg(File $myImage, int $compressionQuality = 70): string
    {
        $filePath = $myImage->getRealPath();
        $myConvertedImage = $filePath . '_jpg';
        $image = new Imagick($myImage);
        $image->readImage($filePath);
        $image->setImageFormat("jpeg");
        $image->setImageCompressionQuality($compressionQuality);
        $image->writeImage($myConvertedImage);
        $image->clear();
        return $myConvertedImage;
    }
}

Context

We want to allow user to allow HEIC file upload from their iPhone, and convert them to allow user to see theim in our image viewer on every devices

Thank you in advance :)

JapanDoudou67 avatar Aug 19 '21 14:08 JapanDoudou67

Hello again :) Did someone test this use case ? I'm always stucked on it ...

JapanDoudou67 avatar Aug 24 '21 14:08 JapanDoudou67

Do you find a fix for that ? Do you still reproduce it ?

mistraloz avatar Nov 04 '21 16:11 mistraloz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please update it if any action still required.

stale[bot] avatar Jan 03 '22 17:01 stale[bot]

This issue has been automatically closed because it has not had recent activity. Please, reopen if you need.

stale[bot] avatar Sep 30 '22 10:09 stale[bot]