2

On my Ubuntu 18.04.1 LTS Server I have ImageMagick, Apache2, Php 7.2 and Php iMagick 3.4.3 set up.

On terminal, convert -version outputs:

Version: ImageMagick 7.0.8-12 Q16 x86_64 2018-10-14 https://imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib heic jbig jng jp2 jpeg lcms lqr lzma openexr pangocairo png ps raw rsvg tiff webp wmf x xml zlib

PhpInfo() for Imagick outputs: Output for PhPinfo

On the terminal, convert pic.x3f pic.jpg works perfectly with no errors and the file is created.

However over php-imagick and apache2 server, $img = new Imagick('temp-upload-path');for the same 'pic.x3f' file returns

Fatal error: Uncaught ImagickException: no decode delegate for this image format `XEF' @ error/constitute.c/ReadImage/556 in /var/www/html/Upload.php:45 Stack trace: #0 /var/www/html/Upload.php(45): Imagick->__construct('/tmp/phpvFoXK3') #1 {main} thrown in /var/www/html/Upload.php on line 45

The same is true for files for formats MDC and RAW, (Can be read in ImageMagick but returns the error on Php's iMagick).

Also, Formats: DCR NRW ARW RW2 SR2 SRF KDC are all successfully read in ImageMagick but on attempting to read and convert them in Php's Imagick, this is returned:

Fatal error: Uncaught ImagickException: TIFF directory is missing required "ImageLength" field. `MissingRequired' @ error/tiff.c/TIFFErrors/650 in /var/www/html/Upload.php:45 Stack trace: #0 /var/www/html/Upload.php(45): Imagick->__construct('/tmp/phpf9Rylo') #1 {main} thrown in /var/www/html/Upload.php on line 45

It appears it is unable to read them via PHP-iMagick which is supposed to link to the system's ImageMagick that successfully reads them. I am yet to discover issues with other formats, jpg, png, tiff, webp etc are all being read fine. This is happening with RAW formats.

Any help is appreciated

1
  • 1
    This is a common issue with Ghostscript. PHP does not use the same ENV variables as your OS. To fix this, add the full path to gs (Ghostscript) in the delegates.xml file for PS entries. Where it shows command=""gs", change it to command=""full_path_to/gs". Add your actual full_path_to/gs. Commented Oct 15, 2018 at 0:06

1 Answer 1

4

Turns out the issue was that since I was pointing PHP-iMagick to the tmp path of the uploaded file, which had no file extension, PHP-iMagick had a hard time processing what the format was. I fixed it by moving the temporary uploaded file to another location and giving it it's original name and extension so that PHP-iMagick can correctly identify the format and read the image as expected.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.