★ wanayoo — archive 1999 http://www.php.net/manual/ja/function.imagecreate.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to グラフィックス
Quick Reference
English version of this pageGerman version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
グラフィックス
* GetImageSize
* ImageArc
* ImageChar
* ImageCharUp
* ImageColorAllocate
* ImageColorDeAllocate
* ImageColorAt
* ImageColorClosest
* ImageColorExact
* ImageColorResolve
* ImageGammaCorrect
* ImageColorSet
* ImageColorsForIndex
* ImageColorsTotal
* ImageColorTransparent
* ImageCopy
* ImageCopyResized
* ImageCreate
* ImageCreateFromGif
* ImageCreateFromJPEG
* ImageCreateFromPNG
* ImageDashedLine
* ImageDestroy
* ImageFill
* ImageFilledPolygon
* ImageFilledRectangle
* ImageFillToBorder
* ImageFontHeight
* ImageFontWidth
* ImageGif
* ImagePng
* ImageJPEG
* ImageInterlace
* ImageLine
* ImageLoadFont
* ImagePolygon
* ImagePSBBox
* ImagePSEncodeFont
* ImagePSFreeFont
* ImagePSLoadFont
* ImagePsExtendFont
* ImagePsSlantFont
* ImagePSText
* ImageRectangle
* ImageSetPixel
* ImageString
* ImageStringUp
* ImageSX
* ImageSY
* ImageTTFBBox
* ImageTTFText
* ImageTypes
* read_exif_data
Manual: ImageCreate
View the source code for this pageSearch the site



Previous page
 ImageCopyResized
 Updated
Sat, 12 Aug 2000
ImageCreateFromGif 
Next page


ImageCreate

(unknown)

ImageCreate -- 新規画像の作成

説明

int imagecreate (int x_size, int y_size)

ImageCreate()は、x_sizey_sizeの空の画像を表わす画像IDを返します。

例 1. 新規にGDイメージストリームを作成し、イメージを出力します。


<?
header ("Content-type: image/png");
$im = @ImageCreate (50, 100)
        or die ("Cannot Initialize new GD image stream");
$background_color = ImageColorAllocate ($im, 255, 255, 255);
$text_color = ImageColorAllocate ($im, 233, 14, 91);
ImageString ($im, 1, 5, 5,  "A Simple Text String", $text_color);
ImagePng ($im);
?>
     

User Contributed Notes: ImageCreate


scott@mha.ca
09-Feb-2000 11:49
okay .. listen .. if you are getting fatal errors attempting to use ImageCreate() then you most probably do not have GD installed .. Likewise, if you are getting fatal errors attempting to use ImageGIF() then you are most probably using a version of GD which does not support the GIF format. Notice that in both of these examples that the problem has nothing to do with PHP or whether or not PHP "supports" any particular function. You must have the GD image library installed to make images work. It is as simple as that. Furthermore, although current versions of GD do NOT support the GIF format, I know that old versions of GD (ie. version 1.3) do support the GIF format but they are probably illegal to use now because of the fuss that unisys has been making about it.


phantom@t-p-l.com
18-Feb-2000 11:11
after some experimenting I've come to the following concusions:
1) if you don't have GD when compiling PHP you have to recompile PHP to enable GD support..
2) imagepng() works the same way as imagegif() just creates png's ..
3) the first color you imagecolormatch becomes the background.. hmm..

hope this helps anyone =)



braxton@austin.ibm.com
01-Mar-2000 12:05
You do not need to recompile php to install the GD. I believe that you can dl() the correct module, instead of linking it statically.


kb2ici@amsat.org
28-Mar-2000 02:49
A sample php image program to create a clock

<PRE>

&lt;?php
header("Content-type: image/gif");

$imSize = 256;
$clockSize = $imSize - 8;

$today = getdate();
$hour = $today[hours];
$minutes = $today[minutes];
$seconds = $today[seconds];
if ($hour >= 12)
{
$hour -= 12;
}
$hourDegress = $hour * 30;
$hourDegress += $minutes / 2;
$minDegress = $minutes * 6;

//* the cordinate system stars at 3:00
$hourDegress -= 90;
if ($hourDegress < 0)
{
$hourDegress += 360;
}
$minDegress -= 90;
if ($minDegress < 0)
{
$minDegress += 360;
}

//* convert to radians
$hourRadians = $hourDegress / 57.295779513082;
$minRadians = $minDegress / 57.295779513082;

$myImage = ImageCreate($imSize, $imSize);

$white = ImageColorAllocate($myImage, 255, 255, 255);
$black = ImageColorAllocate($myImage, 0, 0, 0);
// $red = ImageColorAllocate($myImage, 255, 0, 0);
// $green = ImageColorAllocate($myImage, 0, 255, 0);
$blue = ImageColorAllocate($myImage, 0, 0, 255);

ImageFill($myImage, 0, 0, $blue);
Imageinterlace($myImage, 1);

//* draw the clock circle
Imagearc($myImage, $imSize/2, $imSize/2, $clockSize, $clockSize, 0, 359, $white);

//* draw the hour hand
$hourHandLen = ($clockSize / 2) * 0.6;
$x2 = $imSize/2 + ($hourHandLen * cos($hourRadians));
$y2 = $imSize/2 + ($hourHandLen * sin($hourRadians));
ImageLine($myImage, $imSize/2, $imSize/2, $x2, $y2, $white);

//* draw the minute hand
$minHandLen = ($clockSize / 2) * 0.9;
$x2 = $imSize/2 + ($minHandLen * cos($minRadians));
$y2 = $imSize/2 + ($minHandLen * sin($minRadians));
ImageLine($myImage, $imSize/2, $imSize/2, $x2, $y2, $white);


if ($minutes < 10)
{
$minutes = "0$minutes";
}
Imagestring($myImage, 3, 5, $imSize - 15, ($hour . ":" . $minutes), $white);

Imagegif($myImage);

Imagedestroy($myImage);

?>
</PRE>



speterson@frontier.net
07-Apr-2000 05:13
To all: one possible solution to their problem is the version of PHP installed. PHP ver. 3.0.15 didn't have support for GD 1.8.x libraries. I think that the ver. 3.0.16 solves this problem... but I am not for sure.

Happy coding!



keith@duffin.org
08-Apr-2000 05:35
PHP version 3.0.16 does support the GD 1.8.x libraries. All my previous code works using imagepng instead of imagegif. Be sure to change your header statements to reflect the changes (ie from header("Content-type: image/gif"); to header("Content-type: image/png");) so your images can be saved or offlined properly. Good luck.



benny007@3dgrafika.cz
04-May-2000 08:46
it's same as normal, but you must write ImageCreatePng ... ant other is same only add Png after command ..


rolf.winterscheidt@it-mannesmann.de
24-Jul-2000 03:29
Since I needed some time to get something on my screen, here a small example of creating graphics:

<html>
<head>
</head>
<body>

<?php
$pic=ImageCreate(600,600);
$col1=ImageColorAllocate($pic,200,200,200);
$col2=ImageColorAllocate($pic,0,0,255);
ImageFilledRectangle($pic,1,1,100,100,$col2);
ImagePNG($pic,"pic.png");
ImageDestroy($pic);
?>
<img src=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2Fja%2F%26quot%3Bpic.png%26quot%3B&y=1999 border=0>
</body>
</html>

--
You create a color for the background ($col1, seems to be zero for the background) and one for the boxcolor. The image will be written to disk as pic.png and you get it via normal html-command "img src"... That's it.
Rolf



rupert@complinet.com
02-Aug-2000 12:19
one thing i've noticed is that if, after creating the image, you don't wash it with a background colour, shapes you create on top will 'bleed' to fill the image.


 About Notes


Previous page
 ImageCopyResized
 Updated
Sat, 12 Aug 2000
ImageCreateFromGif 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.