php imagecopy不工作的所有时间

pkbketx9  于 4个月前  发布在  PHP
关注(0)|答案(2)|浏览(47)

我有一个问题与imagecopy$url变量上的某些图像将不会出现,即使有两个工作和不工作的例子PNG$local变量加载透明图像从服务器和$url变量加载从远程服务器。我已经包括了一个测试透明图像为$local

工作时间:

<?php
header("Content-type: image/png");
$url = imagecreatefrompng("url_removed.png");
$local = imagecreatefrompng("http://url_removed.png");
imagecopy($url, $local, 0, 0, 0, 0, 100, 100);
imagepng($url);
imagedestroy($url);
imagedestroy($local);
?>

字符串

不工作:

<?php
header("Content-type: image/png");
$url = imagecreatefrompng("url_removed.png");
$local = imagecreatefrompng("http://url_removed.png");
imagecopy($url, $local, 0, 0, 0, 0, 100, 100);
imagepng($url);
imagedestroy($url);
imagedestroy($local);
?>


我甚至尝试过imagecreatestringfile_get_contents,这也工作,但某些PNG图像,它不像与imagecreatefrompng工作
说了这么多之后,我认为这与imagecopy有关....我能做些什么来解决这个问题,或者还有其他简单的方法吗?

ylamdve6

ylamdve61#

我会用这两个代码测试,它工作

<?php
header("Content-type: image/png");
$url = imagecreatefrompng("http://i.imgur.com/F7Jpk9y.png");
$local = imagecreatefrompng("http://i.imgur.com/0A81XrP.png");
// use imagecopymerge instead and set the copied image opacity to 50
imagecopymerge($url, $local, 0, 0, 0, 0, 64, 64,50); 
imagepng($url);
imagedestroy($url);
imagedestroy($local);
?>

字符串
输出https://i.stack.imgur.com/iqPYe.jpg

w51jfk4q

w51jfk4q2#

一个选项可以是分析php error/warnings logs中的错误文件:

xampp > apache > logs > error.txt

字符串
在那里,您可以找到在图像加载期间导致错误的原因。

相关问题