2012-05-15 44 views
0

我想用php更改圖像的顏色。 如果我想讓它看起來更紅,那麼應用程序中圖像上方的圖像上的透明紅色或更高或更低的圖像可以指示原始照片應該是紅色的。 我可以說gd php函數創建一個顏色的圖像(RGBA)並將其應用於另一個圖像? 謝謝:)php將圖片添加到另一個

+0

您可以製作與您的原稿尺寸相同的大部分透明的純紅色圖像,並將其顯示在上方。有可能是更好的解決方案,儘管 – Jacxel

回答

2

您可以嘗試使用GD的imagecopymerge功能,它將一個圖像複製到另一個圖像,並支持alpha透明度。像這樣的東西應該工作:

<?php 
$redimg = imagecreatetruecolor(100, 100); 
$image = imagecreatefrompng('image.png'); 

// sets background to red 
$red = imagecolorallocate($redimg, 255, 0, 0); 
imagefill($redimg, 0, 0, $red); 

// Merge the red image onto the PNG image 
imagecopymerge($image, $redimg, 0, 0, 0, 0, 100, 100, 75); 

header('Content-type: image/png'); 
imagepng($image); 
imagedestroy($image); 
imagedestroy($redimg); 
?> 

還有更多信息here

+0

完美!謝謝 :) –