【发布时间】:2010-11-16 14:55:13
【问题描述】:
如何加入头部图像和身体图像,以便头部图像精确地固定在身体图像中的颈部。
文件位于:
- 头像:http://yajurinfotech.com/projects/stickers/head1.gif
- 正文:http://yajurinfotech.com/projects/stickers/body2.gif
我尝试了http://yajurinfotech.com/projects/stickers/preview.php。
我目前得到的是:
$h = 'head1.gif';
$b = 'body2.gif';
$headResource = imagecreatefromgif($h);
$bodyResource = imagecreatefromgif($b);
list($headWidth, $headHeight) = getimagesize($h);
list($bodyWidth, $bodyHeight) = getimagesize($b);
$previewHeight = $headHeight+$bodyHeight;
$previewWidth = $headWidth;
$previewResource = imagecreatetruecolor($previewWidth, $previewHeight);
//make background white
$white = imagecolorallocate($previewResource, 255, 255, 255);
imagefill($previewResource, 0, 0, $white);
// Copy head image
imagecopyresized($previewResource,$headResource, ($headHeight/4)+3,($headHeight/2)-3,0,0,$previewWidth/4,$previewHeight/4,$headWidth,$headHeight);
//copy body image
imagecopy($previewResource,$bodyResource,0,$headHeight,0,0,$bodyWidth,$bodyHeight);
header('Content-type: image/gif');
imagegif($previewResource);
正如您在preview.php 中看到的那样,头部图像未正确放置在身体图像之上。
谁能帮我找到一个适用于body2.gif 和body1.gif 的算法?
【问题讨论】:
-
@Sreejith,欢迎来到 stackoverflow!我想我们需要更多信息来回答你的问题——颈部在什么位置结束?头应该是多大?你关心头部“覆盖”一些身体信息吗?
-
首先感谢stackoverflow。谢谢大家的支持。这真的激励了我.. @Dominic,我正在尝试实现类似于此页面中所做的功能:familystickers.com/family-stickers/default.asp 只需向下滚动到页面中的“创建您自己的家庭贴纸”,您就会看到这里实现的东西.我想要相同的功能..
标签: php image-processing image-manipulation