Как можно объединить изображение головы и изображение тела, чтобы изображение головы точно фиксировалось на шее на изображении тела.
Файлы находятся по адресу:
Я предпринял попытку 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
?