图像复制并不总是有效

问题描述 投票:0回答:2

我有一个问题,

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); ?>

imagecreatestring
一起使用,这也有效,但某些
file_get_contents
图像它不像与
PNG
那样工作

说了这么多,我认为这与

imagecreatefrompng

有关......我能做些什么来解决这个问题,或者还有其他简单的方法吗?

    

php gd
2个回答
0
投票

imagecopy

输出

https://i.stack.imgur.com/iqPYe.jpg


0
投票
<?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); ?>

:

error/warnings logs

您可以在其中找到导致图像加载过程中出现错误的原因。

© www.soinside.com 2019 - 2024. All rights reserved.