(PHP 3 <= 3.0.18, PHP 4 >= 4.0.0)
ImageGIF -- Output image to browser or file
Description
int imagegif (int im [, string filename])
ImageGIF() creates the GIF file in filename from the image
im. The im argument is the return from the imagecreate() function.
The image format will be GIF87a unless the image has been made transparent
with ImageColorTransparent(), in which case the image format will be
GIF89a.
The filename argument is optional, and if left off, the raw image stream will be output
directly. By sending an image/gif content-type using
header(), you can create a PHP script that outputs GIF images directly.
Note: Since all GIF support was removed from the GD library in
version 1.6, this function is not available if you are using that version of the GD library.
The following code snippet allows you to write more portable PHP applications by
auto-detecting the type of GD support which is available. Replace the sequence
Header("Content-type: image/gif"); ImageGIF($im); by the more flexible sequence:
<?php
if (function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGIF($im);
}
elseif (function_exists("imagejpeg")) {
Header("Content-type: image/jpeg");
ImageJPEG($im, "", 0.5);
}
elseif (function_exists("imagepng")) {
Header("Content-type: image/png");
ImagePNG($im);
}
elseif (function_exists("imagewbmp")) {
Header("Content-type: image/vnd.wap.wbmp");
ImageWBMP($im);
}
else
die("No image support in this PHP server");
?>
|
Note: As of version 3.0.18 and 4.0.2 you can use the function imagetypes() in place of function_exists() for checking the presence of the
various supported image formats:
if (ImageTypes() ∓ IMG_GIF) {
Header("Content-type: image/gif");
ImageGif($im);
}
elseif (ImageTypes() ∓ IMG_JPG) {
... etc.
|
See also ImagePNG(), ImageWBMP(), ImageJPEG(),
ImageTypes().
|