2016-07-08 1 views
-4

PHPを作成するにはどうすればいいのですか?画像を作成するPHP

enter image description here

(もちろん、テキスト、ボーダー、線、矢印なし。)

+1

[PHP:GD(http://php.net/manual/en/book.image.php)ドキュメント、[関連する質問](HTTP:// stackoverflowの。 com/questions/645582/how-to-graph-in-php)、[一般的なgoogle検索](https://www.google.com/search?q=php%20make%20graph)の可能性があります良いスタートポイントとなる – castis

+0

これはどのように広すぎるのでしょうか?彼は何をしたいのかはっきりしています。境界線を持つ他の3つの画像を含む画像を作ります。彼が与えたサンプル画像が見えなければ、それは広範囲に及ぶだけです。 –

答えて

1

あなたはGDライブラリを使用することができます。

// Load the three image files: 
$images[1]=imagecreatefromjpeg("file1.jpg"); 
$images[2]=imagecreatefromjpeg("file2.jpg"); 
$images[3]=imagecreatefromjpeg("file3.jpg"); 
// Determine their dimensions. 
$totalx=$totaly=0; 
for ($ix in $images) { 
    $img=$images[$ix]; 
    $totalx+=imagesx($img); // get total width 
    $totaly=max($totaly,imagesy($img)); // get maximum height 
} 
$xm=20; // side and in-between margin 
$ym=20; // top and bottom margin 
$totalx+=$xmargin*4; // 2 for the outsides and 2 for the in-betweens 
$totaly+=$ymargin*2; // for top and bottom 
$i=imagecreatetruecolor($totalx,$totaly); 
$xstart=0; // where to place the next image 
for ($ix in $images) { 
    $img=$images[$ix]; 
    $xstart+=$imagesx($img)+$xm; // increase by this image's width plus buffer 
    imagecopy($i,$img,$xstart,$ym,0,0,imagesx($img),imagesy($img)); 
} 
imagepng($i); // this outputs the image data. if you want to write it to a file you can do that with imagepng($i,$filename). 

http://php.net/manual/en/ref.image.php

+0

正しい画像読み込み機能を使用する必要があることに注意してください。たとえば、ソースイメージがPNGの場合、imagecreatefromjpeg()の代わりにimagecreatefrompng()を使用する必要があります。ファイル名をスキャンしたり、mime-typesを使ってイメージフォーマットを決めたり、*()関数から適切なイメージを呼び出すことができます。実際のところ、これらの関数の終わりはMIMEタイプの値と一致します。同様に、PNG以外のものを出力したい場合は、例えば次のように使用する必要があります。 imagepng($ i)の代わりにimagejpeg($ i)を使用します。 –

+0

また、イメージを最終イメージですべて同じサイズにする場合は、imagecopy()コールでimagesx()およびimagesy()の代わりに希望のw/h値を使用できます。私の例では、元の画像と同じサイズにしたいと思っていました。 –

関連する問題