Graphics,Images and PDF
Graphics,Images and PDF
header("Content-Type: image/png");
imagepng($image);
imagedestroy($image);
?>
output
<?php
imagepng($image);
?>
output
Creating a pdf of
document
PDF supports many different embedded
image formats: PNG, JPEG, GIF, TIFF, CCITT,
and a raw image format that consists of a
stream of the exact byte sequence of pixels.
Not every feature of every format is
supported, however.
Adding an image to a PDF document is
relatively simple. The first step is to call the
appropriate open function for the type of
image you are using. These functions all take
the form pdf_open_ format( ). For instance:
$image = pdf_open_jpeg(pdf, filename);
Once you have opened the image, use
pdf_place_image( ) to indicate where in your
document the image should be located. While
you have an image open, you can place it
multiple times throughout your document; your
generated file will contain only one copy of the
actual image data. When you are done placing
your image, call the pdf_close_image( ) function:
pdf_place_image(pdf, image, x, y, scale);
pdf_close_image(pdf, image); The scale
parameter indicates the proportional scaling
factor to be used when placing the image in the
document. You can get the dimensions of an
image via
pdf_get_value( ) calls on the imagewidth and
imageheight keywords.
Some of the image creating
functions
1 imagejpeg()
2 imagegif()
3imagepng()
4imagewbmp()
Imagecolorallocate()
It is used to set the color to image
Syntax-
Imagecolorallocate(image,red,green,blue)
Imagestring(_)
It is used to drop the string on the given
image
Syntax-
imagrstring(image,fontsize,x,y,string,strin
g_color)
Ex-
<?php
$i=imagecreate(500,500);
$back=imagecolorallocate($i,0,200,0);
$text=imagecolorallocate($i,255,255,255
);
$imagestring($i,5,150,200,”Hello PHP “,
$text);
Header(content type:image/jpeg);
Imagejpeg($i);
?>
Scalling image
(1)Imagecreatetruecolor()
This inbuilt function is used to create
anew true color image. It returns an
image identifier representing a blank
image of the specified size.
Syntax-
imagecreatetruecolor(width,height);
(2)imagecopyresampled()
It copies rectangular portion of one image
to another image by smoothly
interpolating pixel values. So that in
particular reducing the size of an image
and still retains its clarity.
Syntax-.
Imagecopyresampled($dst _img,srs_img,
$dst_x,$dst_y,$src_x,$src_y,$dst_w,
$dst_h,$src_w,$src_h);