PHP/Graphics Image — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 10:05, 26 мая 2010
- Arc
- Circle
- Draw String
- Ellipse
- Image Color
- Image Create
- Image Paint
- JPG Image
- Line
- Paint String
- Rectangle
- Round Rectangle
- Text Align
- Transparent
- Triangler
- Water Mark
- imageRectangle
- image_type_to_mime_type
- imagearc
- imagecolorallocate
- imagecolorallocatealpha
- imagecolorexact
- imagecolortransparent
- imagecopymerge
- imagecopyresized
- imagecreatefromgif
- imagecreatefromjpeg
- imagecreatefrompng
- imagecreatetruecolor
- imagedeallocate
- imageellipse
- imagefilledarc
- imagefilledellipse
- imagefilledpolygon
- imagefilledrectangle
- imagefilltoborder
- imagefilter
- imagegif
- imageinterlace
- imagejpeg
- imagepng
- imagepolygon
- imagesetbrush
- imagesetpixel
- imagesetstyle
- imagesettile
- imagestring
- imagettfbbox
- imagettftext
- imagetypes
Содержание
Set font
<source lang="html4strict">
<html> <body> <?php
$img=ImageCreate(300,300); $bgcolor=ImageColorAllocate($img,200,200,200); $red=ImagecolorAllocate($img,255,0,0); $green=ImagecolorAllocate($img,0,255,0); $blue=ImagecolorAllocate($img,0,0,255); $grey=ImagecolorAllocate($img,50,50,50); $black=ImagecolorAllocate($img,0,0,0); for($i=0;$i<10;$i++) { ImageChar($img,$i,20,20+($i*20),"S",$red); $height[]=Imagefontheight($i); $width[]=Imagefontwidth($i); } /* RGB Red = 0..255 , Green = 0..255 , Blue = 0..255. */ ImageSetPixel($img,50,50,$pixelcolor); ImagePNG($img,"pic.png"); ImageDestroy($img); for ($i=0;$i<10;$i++) { echo "font ".$i." height=".$height[$i]."
"; }
?> <img src="pic.png" border=0> </body> </html>
</source>
Set Font size
<source lang="html4strict">
<?php $textImage = imagecreate(200,100); $white = imagecolorallocate($textImage, 255, 255, 255); $black = imagecolorallocate($textImage, 0, 0, 0); $yOffset = 0; for ($i = 1; $i <=5; $i++) {
imagestring($textImage, $i, 5, $yOffset, "www.wbex.ru $i", $black); $yOffset += imagefontheight($i);
} header("Content-type: image/png"); imagepng($textImage); imagedestroy($textImage); ?>
</source>
The TrueType Font Bounding Box
<source lang="html4strict">
<?php
header ("Content-type: image/png"); $font_size = 15; $im = ImageCreate (300, 500); $grey = ImageColorAllocate ($im, 230, 230, 230); $black = ImageColorAllocate ($im, 0, 0, 0); $bbox = ImageTTFBBox($font_size, 0, "ARIALBD.TTF", "Bounding Box!"); for($i = 0; $i < 7; $i++){ ImageTTFText($im, $font_size, 0, 10, ($i * ($font_size * 2)) + 25,$black, "ARIALBD.TTF", "\$bbox[$i] = $bbox[$i]"); } ImagePng ($im); ImageDestroy ($im);
?>
</source>
Use specified font
<source lang="html4strict">
<?php header("Content-type: image/gif"); $image = imagecreate( 400, 200 ); $red = imagecolorallocate($image, 255,0,0); $blue = imagecolorallocate($image, 0,0,255 ); $font = "ARIALBD.TTF"; imageTTFtext( $image, 50, 0, 20, 100, $blue, $font, "www.wbex.ru" ); imagegif($image); ?>
</source>
Use TrueType Fonts
<source lang="html4strict">
<?php
header ("Content-type: image/png"); $im = ImageCreate (300, 40); $grey = ImageColorAllocate ($im, 230, 230, 230); $black = ImageColorAllocate ($im, 0, 0, 0); ImageTTFText($im, 20, 0, 10, 25, $black, "ARIALBD.TTF", "TrueType Fonts!"); ImagePng ($im); ImageDestroy ($im);
?>
</source>