如何在 Windows Vista 上安装 php 的 gmagick 扩展
gmagick 是 imagemagick 的新版本,具有更多功能集,它的资源密集度较低且速度快,但问题是网上关于这个出色工具的讨论很少,我最近在 http://devzone.zend.com/1559/manipulated-图像-with-php-and-graphicsmagick/ 但我无法在 Windows 机器上安装它,因为 phpize 不起作用,所以我尝试了其他方法以及一些如何设法进入 phpinfo 页面,但我无法使其进一步工作,我什至无法使用 gmagick 打开单个图像 这是我使用的代码
<?php
$path="gallery/img1.jpg";
// initialize object
$image = new Gmagick($path);
echo $image;
// read image file
$file = 'gallery/img1.jpg';
$image->readImage($file);
echo '<img src="' . $file . '" width="200" height="150" /> <br/>';
?>
我使用此代码来实例化 gmagick 类并打开图像,但我遇到了很大的错误,如下所示 致命错误:在 C:\xampp\htdocs\junk\imgproc\imgproc1.php:4 中未捕获异常“GmagickException”,并显示消息“无法打开文件 (gallery/img1.jpg)”:4 堆栈跟踪:#0 C:\xampp\ htdocs\junk\imgproc\imgproc1.php(4): Gmagick->__construct('gallery/img1.jp...') #1 {main} 在第 4 行的 C:\xampp\htdocs\junk\imgproc\imgproc1.php 中抛出
gmagick is newer version of imagemagick with more set of features it is less resource intensive and fast but the problem is there is very few discussion about this wonderful tool on web i recently came across this on
http://devzone.zend.com/1559/manipulating-images-with-php-and-graphicsmagick/
but i could not install it on windows machines cos phpize did not work so i tried some other way and some how managed to get on phpinfo page but i could not make it work further i colud not even open a single image with gmagick
this is code i used
<?php
$path="gallery/img1.jpg";
// initialize object
$image = new Gmagick($path);
echo $image;
// read image file
$file = 'gallery/img1.jpg';
$image->readImage($file);
echo '<img src="' . $file . '" width="200" height="150" /> <br/>';
?>
i used this code to instanstiate gmagick class and open image but i am geeting very big error as follows
Fatal error: Uncaught exception 'GmagickException' with message 'Unable to open file (gallery/img1.jpg)' in C:\xampp\htdocs\junk\imgproc\imgproc1.php:4 Stack trace: #0 C:\xampp\htdocs\junk\imgproc\imgproc1.php(4): Gmagick->__construct('gallery/img1.jp...') #1 {main} thrown in C:\xampp\htdocs\junk\imgproc\imgproc1.php on line 4
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
A) 回答标题中的问题(可能会引导其他读者来这里):
PHP GraphicsMagick 扩展的 Windows 版本可以在此处获取:
http://valokuva.org/builds/
通过查看以下内容检查您是否需要线程安全版本网络服务器的
phpinfo();
输出。查找条目线程安全
。在PHP Extension Build
条目中,您还应该找到您需要的VC版本,例如VC9的API20090626,TS,VC9
。下载符合您条件的最新版本,将其放入您的 PHP/ext 目录并将其添加到您的 php.ini 中,如下所示:
如果您使用非 TS 版本,请记住更正 dll 的名称。
重新启动 Apache 并检查 phpinfo();。现在应该有一个
gmagick
块..B) 要纠正代码问题:
readImage()
调用中提供文件。readImage()
和writeImage()
中使用它:这是一段工作代码的示例:
它应该显示图像文件的灰度版本。
A) To answer the question in your headline (that might lead other readers here):
Windows builds of the GraphicsMagick extension for PHP can be obtained here:
http://valokuva.org/builds/
Check whether you need the thread-safe version or not by looking at a
phpinfo();
output of your webserver. Look for the entryThread Safety
. In the entryPHP Extension Build
you should also find the VC version that you need, e.g.API20090626,TS,VC9
for VC9.Download the latest build that matches your conditions, put it into your PHP/ext directory and add it to your php.ini like this:
Remember to correct the name of the dll if you use the non-TS version.
Restart Apache and check
phpinfo();
. There should be agmagick
block now..B) To correct the problem with your code:
readImage()
call.readImage()
andwriteImage()
:Here is an example of a working piece of code:
It should show a grayscale version of your image file.