Imagick PHP extension not working JPEG XR output

I have a problem with ImageMagick . I searched a lot, but did not find a solution. My problem is outputting a JPEG XR image. I am trying to do this in PHP 7.0/7.1 on a Windows 10 and Linux Debian 9 server.

My code is:

 <?php if (TRUE !== extension_loaded('imagick')) { throw new Exception('Imagick extension is not loaded.'); } $image = new Imagick(); $image->newImage(100, 100, new ImagickPixel('red')); // $image->setImageFormat('jpg'); // <-- It works $image->setImageFormat('jxr'); // <-- Fatal error: Uncaught ImagickException: UnableToOpenModuleFile header("Content-Type: image/" . $image->getImageFormat()); echo $image; $image->destroy(); 

The result of phpinfo () on Windows: enter image description here

Windows application:

 C:\Users\Andrei>JxrDecApp.exe JPEG XR Decoder Utility Copyright 2013 Microsoft Corporation - All Rights Reserved ... C:\Users\Andrei>JxrEncApp.exe JPEG XR Encoder Utility Copyright 2013 Microsoft Corporation - All Rights Reserved ... 

JxrDecApp.exe and JxrEncApp.exe are available from any directory!

The result of phpinfo () on Linux: enter image description here

Linux packages:

 root@Server :~# dpkg-query -l | grep jxr ii libjxr-tools 1.1-6+b1 amd64 JPEG-XR lib - command line apps ii libjxr0:amd64 1.1-6+b1 amd64 JPEG-XR lib - libraries root@Server :~# dpkg-query -l | grep imagick ii php-imagick 3.4.3~rc2-2 amd64 Provides a wrapper to the ImageMagick library root@Server :~# JxrDecApp JPEG XR Decoder Utility Copyright 2013 Microsoft Corporation - All Rights Reserved ... root@Server :~# JxrEncApp JPEG XR Encoder Utility Copyright 2013 Microsoft Corporation - All Rights Reserved ... 

Fatal error in Windows :

Uncaught ImagickException: UnableToOpenModuleFile `C: \ WINDOWS \ system32 \ config \ systemprofile \ AppData \ Local \ ImageMagick \ IM_MOD_RL_jxr_.dll ': such a file or directory @ warning / module.c / GetMagickModulePath / 830 in D: \ www \ temp \ xp \ j \ index.php on line 11

Fatal error on Linux :

Unable to set image format

Wiki ImageMagick:

Supported Image Formats:

JXR | RW | Extended Range JPEG | A jxrlib delegate library is required . Put the JxrDecApp and JxrEncApp applications in your execution path. More on this

ChangeLog:

2013-04-29 6.8.5-3 Cristy
Add DeleteImageArtifact () for jpeg: artifact extent (thanks Jimmy Xie @Microsoft).
Add support for the JXR / WDP image format.

Update

echo $_SERVER['PATH']; from PHP to Windows:

 c:\Program Files\ImageMagick-6.9.3-7-vc14-x64\bin\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files\Git\cmd;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files\Java\JDK18~1.0_1\bin;C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.1\plugins\maven\lib\maven3\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\nodejs\;C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.1\bin\;C:\Program Files (x86)\Skype\Phone\;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps 

dir:

 C:\Users\Andrei>dir "c:\Program Files\ImageMagick-6.9.3-7-vc14-x64\bin\*jxr*" 11.11.2017 22:53 464 896 JXRDecApp.exe 11.11.2017 22:53 469 504 JXREncApp.exe 

echo $_SERVER['PATH']; from PHP to Linux:

 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 

run from:

 root@Server :~# which JxrEncApp /usr/bin/JxrEncApp root@Server :~# which JxrDecApp /usr/bin/JxrDecApp 

Question:

How to add support for JXR image format?

+5
source share
2 answers

Good news! The JXR or JPEG Extended Range format is supported by Imagick, but not the way you want. As you are currently trying to access it, this is using a byte array. Compiled by Magick.NET (Imagick.NET library) states the following in a closed Github issue:

The format is supported, but you will need to do some β€œmagic” for it to work. Reading JXR files will only work if you copy the JXRDecApp.exe file to the bin directory and read from a file on a disk with a .jxr extension. Reading from an array of bytes is not supported. It would be nice if the jxrlib project code ( http://jxrlib.codeplex.com ) could be part of ImageMagick. Perhaps I should create a problem for this in the ImageMagick project. You will need to compile JXRDecApp.exe yourself, because there are no binaries available.

Thus, the JXR format is supported, but not in the way you want to apply it. However, the conversion can be done using the command line, as described in StackOverflow here or how.

 convert input.jpg jxr:output.jpg 

It remains to write a script that executes this command to perform the conversion for you. Make sure that you script the script correctly and it inputs and outputs. Good luck

A source:

0
source

Some PHP packages ship with their Imagick package, rather than using a system package. You can then find what is supported on the command line and what PHP supports as a result.

In the source, PHP directly obtains a list of supported formats from Imagick itself.

If these are not different versions, there may be a hidden abstraction, where jxr is an alias for another parent format with certain options.

-1
source

Source: https://habr.com/ru/post/1273342/


All Articles