0
即時嘗試覆蓋到一個JPEG的PNG,到目前爲止它的工作,但由於某種原因,PNG阿爾法沒有被使用,你可以看到它有一個黑色的背景,它應該透明。 PHP疊加圖像,阿爾法正在丟失
代碼:
<?php
header('Content-Type: image/jpeg');
$source_image = imagecreatefromjpeg("data/images/20140123/0/sexy-briana-evigan-gets-worked-up-and-wet.jpg");
$source_imagex = imagesx($source_image);
$source_imagey = imagesy($source_image);
$overlay_max_width = $source_imagex * 40/100;
//Resize overlay to fit
$overlay = imagecreatefrompng("overlay.png");
$overlay_imagex = imagesx($overlay);
$overlay_imagey = imagesy($overlay);
$ratio = $overlay_max_width/$overlay_imagex;
$newwidth = $overlay_max_width;
$newheight = $overlay_imagey * $ratio;
//Make new size
$overlay_image = imagecreatetruecolor($newwidth,$newheight);
imagecopyresized($overlay_image, $overlay, 0, 0, 0, 0, $newwidth, $newheight, $overlay_imagex, $overlay_imagey);
imagecopymerge($source_image, $overlay_image,$source_imagex-$newwidth,$source_imagey-$newheight,0,0, imagesx($source_image),imagesy($source_image),100);
imagejpeg($source_image,null,100);
?>