6

PHP で画像を作成することは可能ですか (単純に HTML 経由で画像にリンクするのではなく)。

4

7 に答える 7

12

私はGD ライブラリを好みます - Examplesとこの例をチェックしてください:

<?php
header ("Content-type: image/png");
$im = @imagecreatetruecolor(120, 20)
      or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>

出力:

imagecreatetrucolor の例
(出典: php.net )

imagecreatetruecolorを参照してください。

于 2008-08-24T16:11:39.580 に答える
6

はい、これは可能です。これを達成するためのライブラリは複数あると思います。最も広く使用されているのはおそらくImageMagickです。これは実際には PHP 固有ではありませんが、適切なバインディングが付属しています。

PHP ドキュメントも参照してください。

于 2008-08-24T16:04:32.437 に答える
3

GDをチェックしてください。画像の作成、操作、尋問のための機能がたくさん含まれています。あなたのPHPインストールは、おそらくそうであったGDライブラリで構築する必要があります。

于 2008-08-24T16:06:31.653 に答える
3

PHP を使用した画像生成に関するまともなチュートリアル:

GD - http://devzone.zend.com/node/view/id/1269

ImageMagick - http://www.sitepoint.com/article/dynamic-images-imagemagick

于 2008-08-24T16:33:40.997 に答える
1

PHPGD

Pear Image_Canvas (およびグラフの場合はImage_Graph )

私の知っている二人です。

于 2008-08-24T16:11:21.097 に答える
0

gd ライブラリをさまざまな機能で使用できます。コードで良いイメージを作成します

header("Content-Type: image/png");

//try to create an image
$im = @imagecreate(800, 600)
or die("Cannot Initialize new GD image stream");

//set the background color of the image
$background_color = imagecolorallocate($im, 0xFF, 0xCC, 0xDD);

//set the color for the text 
$text_color = imagecolorallocate($im, 133, 14, 91);

//adf the string to the image
imagestring($im, 5, 300, 300,  "I'm a pretty picture:))", $text_color);

//outputs the image as png
imagepng($im);

//frees any memory associated with the image 
imagedestroy($im);

色をネガに

if(!file_exists('dw-negative.png')) {
    $img = imagecreatefrompng('dw-manipulate-me.png');
    imagefilter($img,IMG_FILTER_NEGATE);
    imagepng($img,'db-negative.png');
    imagedestroy($img);
}
于 2015-10-01T11:40:25.080 に答える
0

MagickWand はその点でも非常に優れており、非常に強力です。

http://www.bitweaver.org/doc/magickwand/index.html

このスニペットは、画像を取得し、Vera または利用可能なフォントで「バラ」を書き込み、その画像をブラウザーにフラッシュします。

$drawing_wand=NewDrawingWand();
DrawSetFont($drawing_wand,"/usr/share/fonts/bitstream-vera/Vera.ttf");
DrawSetFontSize($drawing_wand,20);
DrawSetGravity($drawing_wand,MW_CenterGravity);
$pixel_wand=NewPixelWand();
PixelSetColor($pixel_wand,"white");
DrawSetFillColor($drawing_wand,$pixel_wand);
if (MagickAnnotateImage($magick_wand,$drawing_wand,0,0,0,"Rose") != 0) {
    header("Content-type: image/jpeg");
MagickEchoImageBlob( $magick_wand );
} else {
echo MagickGetExceptionString($magick_wand);
}
于 2009-05-16T00:28:08.923 に答える