dongmou3615 2015-09-02 15:00
浏览 63

PHP PNG透明度

I have a code which is converting PNG to PNG (the PNG is originally bad! There is no transparency) so my task is to restore the transpareny.

$image = imageCreateFromPng("./kep.png");
$background = imagecolorallocate($image, 0, 0, 0);
imagecolortransparent($image, $background);
imagealphablending($image, false);
imagesavealpha($image, true);
header('Content-type: image/png');
imagepng($image,NULL);

This is my code but not working. I receive a black backgrounded picture. I have googled hours but nothing helped.

The original PNG has BLACK color when i open it with Photoshop. I want to make a code which make a good transparent png from the bad png.

(If i open the bad png with gimp, then save as png the transparency is good, but i need something automatically.)

What i missed? Thanks!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有人能看一下我宿舍管理系统的报修功能该怎么改啊?链表那里总是越界
    • ¥15 cs loadimage运行不了,easyx也下了,没有用
    • ¥15 r包runway详细安装教程
    • ¥15 Html中读取Json文件中数据并制作表格
    • ¥15 谁有RH342练习环境
    • ¥15 STM32F407 DMA中断问题
    • ¥15 uniapp连接阿里云无法发布消息和订阅
    • ¥25 麦当劳点餐系统代码纠错
    • ¥15 轮班监督委员会问题。
    • ¥20 关于变压器的具体案例分析