2017-05-18 31 views
0

我有一個背景圖片現在我想PHP把對其它圖像頂部它(其它圖像存儲在一個變量) 實例變量$ X &我的背景圖像另外一個變量$回 例../img/back.jpg 現在,我要補充的$ X上的背景 左側我會如何實現這一目標? 喜歡這張圖有陰影圖像的綠色部分 如何用另一張使用PHP的圖片替換那部分? (https://i.stack.imgur.com/IjK0o.jpg) 我有什麼事這麼遠如何添加圖片上方的另一個使用PHP

<?php 
copy("https://graph.facebook.com/FACEBOOKID/picture?width=99&height=99", "picture.jpg"); 
$x = "picture.jpg"; 
copy("https://i.stack.imgur.com/IjK0o.jpg","bg.jpg"); 
$back = "bg.jpg"; 
?> 
+0

見'imagecopy的()'http://php.net/manual/en/function.imagecopy.php和所有其他的複印功能。 –

+0

的可能的複製[我如何在HTML的另一個頂部位置一個圖像?](http://stackoverflow.com/questions/48474/how-do-i-position-one-image-on-top-of-另外,在-HTML) – Andreas

+0

@Andreas我不認爲這是一個重複的。 OP希望輸出成爲圖像,而不是HTML。 –

回答

0

合成圖像是圖像處理的一部分。您可以直接使用gd library。不過,我建議使用OO圖像處理庫,如intervention image,這更容易編寫和理解。

// open the background image file 
$img = Image::make('bg.jpg'); 

// Add the facebook image 
$img->insert('picture.jpg'); 

// Save the image as a new file 
$img->save('newpicture.jpg'); 

閱讀有關insert method的文檔來了解如何將Facebook的圖像位置。

相關問題