首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用php文件生成的png生成imagecreatefrompng()

用php文件生成的png生成imagecreatefrompng()
EN

Stack Overflow用户
提问于 2013-05-30 12:58:42
回答 1查看 1.7K关注 0票数 1

我的代码出错了

代码语言:javascript
复制
header ("Content-type: image/jpeg"); 

$nomphoto = "antigua.jpg";

// On charge d'abord les images
$source = imagecreatefrompng('logo.php');


$destination = imagecreatefromjpeg($nomphoto); 


$largeur_source = imagesx($source);
$hauteur_source = imagesy($source);
$largeur_destination = imagesx($destination);
$hauteur_destination = imagesy($destination);



$destination_x = 0;
$destination_y =  ($hauteur_destination / 1.5) - ($hauteur_source / 2);


imagecopymerge($destination, $source, $destination_x, $destination_y, 0, 0, $largeur_source, $hauteur_source, 60);


imagejpeg($destination);

我无法从logo.php加载图片

logo.php码

代码语言:javascript
复制
$imgPng = imagecreatefrompng("logo24.png");
imagealphablending($imgPng, true);
imageSaveAlpha($imgPng, true);

header("Content-type: image/png");
imagePng($imgPng); 

我想把我的png-24图像版权。logo.php工作得很好,我可以得到图片,但是当我将它与图像一起使用时,它就不工作了。

我试过使用imagecreatefrompng(file_get_contents('logo.php'));,但它也不起作用。我想要的是把我的png-24版权图片放在我的jpg (保持透明度)你有什么解决方案吗?

EN

回答 1

Stack Overflow用户

发布于 2018-03-13 17:34:35

执行部分的解决方案。

而不是使用imagecopymerge(),,必须使用映像()

代码语言:javascript
复制
imagecopy($destination, $source, $destination_x, $destination_y, 0, 0, $largeur_source, $hauteur_source);

然后就不需要logo.php代码了。只需加载png-24图像。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16836887

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档