2

ある画像を別の画像の下部に表示しようとしています。これを実現するために、次のリンクで説明されている方法を使用し ました。PHP で別の画像の下部にある画像を追加する方法は非常に便利です。ただし、私の場合、imagerotateプロパティも使用する必要があるため、期待される結果が得られません。

私のコードは次のとおりです。

$top_file='photo1.png';
$bottom_file='photo2.png';
$degrees=270;

$top = imagecreatefrompng($top_file);
$bottom = imagecreatefrompng($bottom_file);

// Rotates the images
$rotatetop = imagerotate($top, $degrees, 0);
$rotatebottom = imagerotate($bottom, $degrees, 0);

// get current width/height
list($top_width, $top_height) = getimagesize($top_file);
list($bottom_width, $bottom_height) = getimagesize($bottom_file);

// compute new width/height
$new_width = ($top_width > $bottom_width) ? $top_width : $bottom_width;
$new_height = $top_height + $bottom_height;

// create new image and merge
$new = imagecreate($new_height, $new_width);
imagecopy($new, $rotatetop, 0, 0, 0, 0, $top_width, $top_height);
imagecopy($new, $rotatebottom, 0, $top_height+1, 0, 0, $bottom_width, $bottom_height);

// save to file and display on the browser
imagepng($new,'merged_image.png');
echo '<img src="merged_image.png" alt="Not available" />';

関数からプロパティを変更しようとしましたimagecopyが、正しい方法が見つかりません。

誰かが適切な設定を選択するのを手伝ってくれたら幸いです。

私が得たものの例をここに添付します:ここに画像の説明を入力

4

0 に答える 0