2014-02-20 26 views
1

我需要創建一個具有一定大小(45釐米寬x 32釐米高)的白色背景Imagick PHP的圖像,並複製他在一個圖像,我有一個文件夾中的某個固定位置。插入圖像到另一個圖像Imagick

我可以幫忙嗎?

問候,並非常感謝你

+0

查看本項[如何合併3 i mages成1圖像通過PHP?](http://stackoverflow.com/questions/4419383/how-can-i-merge-3-images-into-1-image-via-php) –

+0

看到http:// stackoverflow .com/questions/3876299/merge-two-images-with-php –

回答

1

imagecopy是你需要的功能

作物形象的例子:

<?php 
// Create image instances 
$src = imagecreatefromgif('php.gif'); 
$dest = imagecreatetruecolor(80, 40); 

// Copy 
imagecopy($dest, $src, 0, 0, 20, 13, 80, 40); 

// Output and free from memory 
header('Content-Type: image/gif'); 
imagegif($dest); 

imagedestroy($dest); 
imagedestroy($src); 
?> 

,如果你只需要添加一個白色背景imagefill是你的函數:

$image = imagecreatetruecolor(100, 100); 

// set background to white 
$white = imagecolorallocate($im, 255, 255, 255); 
imagefill($image, 0, 0, $white); 
+0

好的,編輯這個解決方案一點,我用來做我想做的事。 問候,非常感謝你 – Ferrete

+0

這段代碼生成一個黑色的背景圖像,因爲我有白色背景嗎? – Ferrete

+0

白色背景需要添加的代碼 –