Home > Backend Development > PHP Tutorial > imagick无法对远程url图片进行编辑问题

imagick无法对远程url图片进行编辑问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:29:55
Original
1685 people have browsed it

<code><?php header("content-type: image/png");
$handle = fopen('http://i3.tietuku.com/2afd667e3eded5e0.png', 'rb');
$img = new Imagick();
$img->readImageFile($handle);
$img->resizeImage(128, 128, 0, 0);

echo $img;
</code>
Copy after login
Copy after login

大家看我的这段代码,我是按照php官方文档的示例代码写的代码,理论上代码质量是有保障的,但是我还是报出了错误:

<code>( ! ) Fatal error: Uncaught exception 'ImagickException' with message 'Unable to read image from the filehandle' in D:\wampServer\www\test\index.php on line 5
( ! ) ImagickException: Unable to read image from the filehandle in D:\wampServer\www\test\index.php on line 5
Call Stack
#	Time	Memory	Function	Location
1	0.0000	139136	{main}( )	..\index.php:0
2	0.0700	150424	readimagefile ( )	..\index.php:5</code>
Copy after login
Copy after login

我在本地测试是没问题的,可以用 绝对路径 打开图片,进行正常的图片操作。
下面是环境展示:
imagick无法对远程url图片进行编辑问题

求各位朋友指点一二,怎么解决这个问题?

回复内容:

<code><?php header("content-type: image/png");
$handle = fopen('http://i3.tietuku.com/2afd667e3eded5e0.png', 'rb');
$img = new Imagick();
$img->readImageFile($handle);
$img->resizeImage(128, 128, 0, 0);

echo $img;
</code>
Copy after login
Copy after login

大家看我的这段代码,我是按照php官方文档的示例代码写的代码,理论上代码质量是有保障的,但是我还是报出了错误:

<code>( ! ) Fatal error: Uncaught exception 'ImagickException' with message 'Unable to read image from the filehandle' in D:\wampServer\www\test\index.php on line 5
( ! ) ImagickException: Unable to read image from the filehandle in D:\wampServer\www\test\index.php on line 5
Call Stack
#	Time	Memory	Function	Location
1	0.0000	139136	{main}( )	..\index.php:0
2	0.0700	150424	readimagefile ( )	..\index.php:5</code>
Copy after login
Copy after login

我在本地测试是没问题的,可以用 绝对路径 打开图片,进行正常的图片操作。
下面是环境展示:
imagick无法对远程url图片进行编辑问题

求各位朋友指点一二,怎么解决这个问题?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template