内の別の下部に1枚の画像を追加します1枚の写真にそれらを追加し、上下を一緒に表示したい。は</p> <p>私は、これはイメージをロードしてきた私はPHPで別の底に一つの画像を追加したいPHP
どうすればいいですか?
ありがとうございます!
内の別の下部に1枚の画像を追加します1枚の写真にそれらを追加し、上下を一緒に表示したい。は</p> <p>私は、これはイメージをロードしてきた私はPHPで別の底に一つの画像を追加したいPHP
どうすればいいですか?
ありがとうございます!
使用imagecopy:
$top_file = 'image1.png';
$bottom_file = 'image2.png';
$top = imagecreatefrompng($top_file);
$bottom = imagecreatefrompng($bottom_file);
// 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_width, $new_height);
imagecopy($new, $top, 0, 0, 0, 0, $top_width, $top_height);
imagecopy($new, $bottom, 0, $top_height+1, 0, 0, $bottom_width, $bottom_height);
// save to file
imagepng($new, 'merged_image.png');
a)の画像を組み合わせて、ファイル Bに結果を格納)それを指すように、適切なタグを生成 にあなたが持っているでしょうこれを達成します。 c)そのファイル名をもう一度使用しないでください。
2枚の画像を1回だけ結合したい場合は、画像マジックを使用します。
2つのイメージを1つずつ表示したい場合は、適切なhtmlを使用して、ブラウザで表示させます。
など。
<div><div><img.../></div><div><img .../></div></div>
イメージを通常の方法でphpで生成します。ここに表示するためのタグを取得するよりも簡単です (:)
$photo_to_paste = "photo_to_paste.png";
$white_image = "white_image.png";
$im = imagecreatefrompng($white_image);
$im2 = imagecreatefrompng($photo_to_paste);
// Place "photo_to_paste.png" on "white_image.png"
imagecopy($im, $im2, 20, 10, 0, 0, imagesx($im2), imagesy($im2));
// Save output image.
imagepng($im, "output.png", 0);
この質問に対する答えではないかもしれませんが、両方の画像を重ねて表示したい場合は、これが答えであるため、これはダウンボートに値するものではありません – Wanjia
これは彼が尋ねたもののように、まったく聞こえない...彼のユースケースを知らなくても、これはおそらく、実行可能なソリューションではありません。私は彼がCSSのスプライトのためにそれをしたいと思っています。 – mpen