我对 ImageMagick 有疑问。我搜索了很多,但没有找到解决方案。我的问题与输出到 JPEG XR 格式有关。我正在尝试在 Windows 10 和 Linux Debian 9 服务器上的 PHP 7.0/7.1 中执行此操作。
我的代码:
<?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();
Windows 应用:
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 和 JxrEncApp.exe 可从任何目录获取!
Linux 软件包:
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
...
Windows 上的 fatal error :
Uncaught ImagickException: UnableToOpenModuleFile `C:\WINDOWS\system32\config\systemprofile\AppData\Local\ImageMagick\IM_MOD_RL_jxr_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/830 in D:\www\temp\jxr\index.php on line 11
Linux 上的 fatal error :
Unable to set image format
维基 ImageMagick:
支持的图像格式:
JXR | RW | JPEG extended range | Requires the jxrlib delegate library. Put the JxrDecApp and JxrEncApp applications in your execution path. Read more this
变更日志:
2013-04-29 6.8.5-3 Cristy
Add DeleteImageArtifact() for jpeg:extent artifact (thanks to Jimmy Xie @ Microsoft).
Add support for JXR / WDP image format.
更新
echo $_SERVER['PATH']; 来自 Windows 上的 PHP:
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
目录:
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']; 来自 Linux 上的 PHP:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
执行自:
root@Server:~# which JxrEncApp
/usr/bin/JxrEncApp
root@Server:~# which JxrDecApp
/usr/bin/JxrDecApp
问题:
如何添加对 JXR 图片格式的支持?
最佳答案
好消息! Imagick 支持 JXR 或 JPEG Extended Range 格式,但不是以您希望的方式支持。您当前尝试访问它的方式是通过使用字节数组。 Magick.NET(Imagick .NET 库)的维护者在 Github 上的一个已关闭问题中声明如下:
The format is supported but you will need to do some 'magick' to make it work. Reading JXR files will only work when you copy the file JXRDecApp.exe to your bin directory and read from a file on disk that has a .jxr extension. Reading from a byte array is not supported. It would be nice if the code of the jxrlib project (http://jxrlib.codeplex.com) could be part of ImageMagick. Maybe I should create an issue for this in the ImageMagick project. You will need to compile JXRDecApp.exe yourself because there are no binaries available.
因此支持 JXR 格式,但不是以您希望的方式应用它。但是,可以按照 StackOverflow 中所述通过命令行完成转换 here或者像这样。
convert input.jpg jxr:output.jpg
剩下的就是编写一个执行此命令的脚本来为您进行转换。确保您正确保护该脚本及其输入和输出。祝你好运!
来源:
关于php - Imagick PHP 扩展无法输出 JPEG XR 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47279769/
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我正在编写一个包含C扩展的gem。通常当我写一个gem时,我会遵循TDD的过程,我会写一个失败的规范,然后处理代码直到它通过,等等......在“ext/mygem/mygem.c”中我的C扩展和在gemspec的“扩展”中配置的有效extconf.rb,如何运行我的规范并仍然加载我的C扩展?当我更改C代码时,我需要采取哪些步骤来重新编译代码?这可能是个愚蠢的问题,但是从我的gem的开发源代码树中输入“bundleinstall”不会构建任何native扩展。当我手动运行rubyext/mygem/extconf.rb时,我确实得到了一个Makefile(在整个项目的根目录中),然后当
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
我正在使用puppet为ruby程序提供一组常量。我需要提供一组主机名,我的程序将对其进行迭代。在我之前使用的bash脚本中,我只是将它作为一个puppet变量hosts=>"host1,host2"我将其提供给bash脚本作为HOSTS=显然这对ruby不太适用——我需要它的格式hosts=["host1","host2"]自从phosts和putsmy_array.inspect提供输出["host1","host2"]我希望使用其中之一。不幸的是,我终其一生都无法弄清楚如何让它发挥作用。我尝试了以下各项:我发现某处他们指出我需要在函数调用前放置“function_”……这
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
这是一道面试题,我没有答对,但还是很好奇怎么解。你有N个人的大家庭,分别是1,2,3,...,N岁。你想给你的大家庭拍张照片。所有的家庭成员都排成一排。“我是家里的friend,建议家庭成员安排如下:”1岁的家庭成员坐在这一排的最左边。每两个坐在一起的家庭成员的年龄相差不得超过2岁。输入:整数N,1≤N≤55。输出:摄影师可以拍摄的照片数量。示例->输入:4,输出:4符合条件的数组:[1,2,3,4][1,2,4,3][1,3,2,4][1,3,4,2]另一个例子:输入:5输出:6符合条件的数组:[1,2,3,4,5][1,2,3,5,4][1,2,4,3,5][1,2,4,5,3][
我在pry中定义了一个函数:to_s,但我无法调用它。这个方法去哪里了,怎么调用?pry(main)>defto_spry(main)*'hello'pry(main)*endpry(main)>to_s=>"main"我的ruby版本是2.1.2看了一些答案和搜索后,我认为我得到了正确的答案:这个方法用在什么地方?在irb或pry中定义方法时,会转到Object.instance_methods[1]pry(main)>defto_s[1]pry(main)*'hello'[1]pry(main)*end=>:to_s[2]pry(main)>defhello[2]pry(main)