PHP Image Functions

EditRocket provides the following information on Image functions in the PHP source code builder.

array gd_info ( void ) - Gets information about the version and capabilities of the installed GD library.

array getimagesize ( string $filename [, array &$imageinfo ] ) -

bool image2wbmp ( resource $image [, string $filename [, int $threshold ]] ) -

string image_type_to_extension ( int $imagetype [, bool $include_dot ] ) - Returns the extension for the given IMAGETYPE_XXX constant.

string image_type_to_mime_type ( int $imagetype ) - The image_type_to_mime_type() function will determine the Mime-Type for an IMAGETYPE constant.

bool imagealphablending ( resource $image , bool $blendmode ) - imagealphablending() allows for two different modes of drawing on truecolor images.

bool imageantialias ( resource $image , bool $on ) - Activate the fast drawing antialiased methods for lines and wired polygons. It does not support alpha components. It works using a direct blend operation. It works only with truecolor images.

bool imagearc ( resource $image , int $cx , int $cy , int $width , int $height , int $start , int $end , int $color ) - imagearc() draws an arc of circle centered at the given coordinates.

bool imagechar ( resource $image , int $font , int $x , int $y , string $c , int $color ) - imagechar() draws the first character of c in the image identified by image with its upper-left at x,y (top left is 0, 0) with the color color.

bool imagecharup ( resource $image , int $font , int $x , int $y , string $c , int $color ) - Draws the character c vertically at the specified coordinate on the given image.

int imagecolorallocate ( resource $image , int $red , int $green , int $blue ) -

int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha ) -

int imagecolorat ( resource $image , int $x , int $y ) - Returns the index of the color of the pixel at the specified location in the image specified by image.

int imagecolorclosest ( resource $image , int $red , int $green , int $blue ) -

int imagecolorclosestalpha ( resource $image , int $red , int $green , int $blue , int $alpha ) -

int imagecolorclosesthwb ( resource $image , int $red , int $green , int $blue ) -

bool imagecolordeallocate ( resource $image , int $color ) -

int imagecolorexact ( resource $image , int $red , int $green , int $blue ) - Returns the index of the specified color in the palette of the image.

int imagecolorexactalpha ( resource $image , int $red , int $green , int $blue , int $alpha ) - Returns the index of the specified color+alpha in the palette of the image.

bool imagecolormatch ( resource $image1 , resource $image2 ) -

int imagecolorresolve ( resource $image , int $red , int $green , int $blue ) - This function is guaranteed to return a color index for a requested color, either the exact color or the closest possible alternative.

int imagecolorresolvealpha ( resource $image , int $red , int $green , int $blue , int $alpha ) - This function is guaranteed to return a color index for a requested color, either the exact color or the closest possible alternative.

void imagecolorset ( resource $image , int $index , int $red , int $green , int $blue ) - This sets the specified index in the palette to the specified color. This is useful for creating flood-fill-like effects in palleted images without the overhead of performing the actual flood-fill.

array imagecolorsforindex ( resource $image , int $index ) - Gets the color for a specified index.

int imagecolorstotal ( resource $image ) - Returns the number of colors in an image palette.

int imagecolortransparent ( resource $image [, int $color ] ) - Sets the transparent color in the given image.

bool imageconvolution ( resource $image , array $matrix , float $div , float $offset ) - Applies a convolution matrix on the image, using the given coefficient and offset.

bool imagecopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h ) - Copy a part of src_im onto dst_im starting at the x,y coordinates src_x, src_y with a width of src_w and a height of src_h. The portion defined will be copied onto the x,y coordinates, dst_x and dst_y.

bool imagecopymerge ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h , int $pct ) - Copy a part of src_im onto dst_im starting at the x,y coordinates src_x, src_y with a width of src_w and a height of src_h. The portion defined will be copied onto the x,y coordinates, dst_x and dst_y.

bool imagecopymergegray ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h , int $pct ) - imagecopymergegray() copy a part of src_im onto dst_im starting at the x,y coordinates src_x, src_y with a width of src_w and a height of src_h. The portion defined will be copied onto the x,y coordinates, dst_x and dst_y.

bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) - imagecopyresampled() copies a rectangular portion of one image to another image, smoothly interpolating pixel values so that, in particular, reducing the size of an image still retains a great deal of clarity.

bool imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) - imagecopyresized() copies a rectangular portion of one image to another image. dst_image is the destination image, src_image is the source image identifier. If the source and destination coordinates and width and heights differ, appropriate stretching or shrinking of the image fragment will be performed. The coordinates refer to the upper left corner. This function can be used to copy regions within the same image (if dst_image is the same as src_image) but if the regions overlap the results will be unpredictable.

resource imagecreate ( int $width , int $height ) - imagecreate() returns an image identifier representing a blank image of specified size.

resource imagecreatefromgd ( string $filename ) -

resource imagecreatefromgd2 ( string $filename ) -

resource imagecreatefromgd2part ( string $filename , int $srcX , int $srcY , int $width , int $height ) -

resource imagecreatefromgif ( string $filename ) - imagecreatefromgif() returns an image identifier representing the image obtained from the given filename.

resource imagecreatefromjpeg ( string $filename ) - imagecreatefromjpeg() returns an image identifier representing the image obtained from the given filename.

resource imagecreatefrompng ( string $filename ) - imagecreatefrompng() returns an image identifier representing the image obtained from the given filename.

resource imagecreatefromstring ( string $data ) - imagecreatefromstring() returns an image identifier representing the image obtained from the given data These types will be automatically detected if your build of PHP supports them: JPEG, PNG, GIF, WBMP, and GD2.

resource imagecreatefromwbmp ( string $filename ) - imagecreatefromwbmp() returns an image identifier representing the image obtained from the given filename.

resource imagecreatefromxbm ( string $filename ) - imagecreatefromxbm() returns an image identifier representing the image obtained from the given filename.

resource imagecreatefromxpm ( string $filename ) - imagecreatefromxpm() returns an image identifier representing the image obtained from the given filename.

resource imagecreatetruecolor ( int $width , int $height ) - imagecreatetruecolor() returns an image identifier representing a black image of the specified size.

bool imagedashedline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) - This function is deprecated.

bool imagedestroy ( resource $image ) - imagedestroy() frees any memory associated with image image.

bool imageellipse ( resource $image , int $cx , int $cy , int $width , int $height , int $color ) - Draws an ellipse centered at the specified coordinates.

bool imagefill ( resource $image , int $x , int $y , int $color ) - Performs a flood fill starting at the given coordinate (top left is 0, 0) with the given color in the image.

bool imagefilledarc ( resource $image , int $cx , int $cy , int $width , int $height , int $start , int $end , int $color , int $style ) - Draws a partial ellipse centered at the specified coordinate in the given image.

bool imagefilledellipse ( resource $image , int $cx , int $cy , int $width , int $height , int $color ) - Draws an ellipse centered at the specified coordinate on the given image.

bool imagefilledpolygon ( resource $image , array $points , int $num_points , int $color ) - imagefilledpolygon() creates a filled polygon in the given image.

bool imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) - Creates a rectangle filled with color in the given image starting at point 1 and ending at point 2. 0, 0 is the top left corner of the image.

bool imagefilltoborder ( resource $image , int $x , int $y , int $border , int $color ) - imagefilltoborder() performs a flood fill whose border color is defined by border. The starting point for the fill is x, y (top left is 0, 0) and the region is filled with color color.

bool imagefilter ( resource $image , int $filtertype [, int $arg1 [, int $arg2 [, int $arg3 [, int $arg4 ]]]] ) - imagefilter() applies the given filter filtertype on the image.

int imagefontheight ( int $font ) - Returns the pixel height of a character in the specified font.

int imagefontwidth ( int $font ) - Returns the pixel width of a character in font.

array imageftbbox ( float $size , float $angle , string $font_file , string $text [, array $extrainfo ] ) -

array imagefttext ( resource $image , float $size , float $angle , int $x , int $y , int $col , string $font_file , string $text [, array $extrainfo ] ) -

bool imagegammacorrect ( resource $image , float $inputgamma , float $outputgamma ) - Applies gamma correction to the given gd image given an input and an output gamma.

bool imagegd ( resource $image [, string $filename ] ) - Outputs a GD image to the given filename.

bool imagegd2 ( resource $image [, string $filename [, int $chunk_size [, int $type ]]] ) - Outputs a GD2 image to the given filename.

bool imagegif ( resource $image [, string $filename ] ) -

resource imagegrabscreen ( void ) - Grabs a screenshot of the whole screen.

resource imagegrabwindow ( int $window [, int $client_area ] ) - Grabs a window or its client area using a windows handle (HWND property in COM instance)

int imageinterlace ( resource $image [, int $interlace ] ) - imageinterlace() turns the interlace bit on or off.

bool imageistruecolor ( resource $image ) - imageistruecolor() finds whether the image image is a truecolor image.

bool imagejpeg ( resource $image [, string $filename [, int $quality ]] ) -

bool imagelayereffect ( resource $image , int $effect ) - Set the alpha blending flag to use the bundled libgd layering effects.

bool imageline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) - imageline() draws a line between the two given points.

int imageloadfont ( string $file ) - imageloadfont() loads a user-defined bitmap and returns its identifier.

void imagepalettecopy ( resource $destination , resource $source ) - imagepalettecopy() copies the palette from the source image to the destination image.

bool imagepng ( resource $image [, string $filename [, int $quality [, int $filters ]]] ) -

bool imagepolygon ( resource $image , array $points , int $num_points , int $color ) - imagepolygon() creates a polygon in the given image.

array imagepsbbox ( string $text , int $font , int $size [, int $space ], int $tightness , float $angle ) - Gives the bounding box of a text rectangle using PostScript Type1 fonts.

bool imagepsencodefont ( resource $font_index , string $encodingfile ) - Loads a character encoding vector from a file and changes the fonts encoding vector to it. As a PostScript fonts default vector lacks most of the character positions above 127, you'll definitely want to change this if you use an other language than English.

bool imagepsextendfont ( int $font_index , float $extend ) - Extend or condense a font (font_index), if the value of the extend parameter is less than one you will be condensing the font.

bool imagepsfreefont ( resource $fontindex ) - imagepsfreefont() frees memory used by a PostScript Type 1 font.

resource imagepsloadfont ( string $filename ) - Load a PostScript Type 1 font from the given filename.

bool imagepsslantfont ( resource $font_index , float $slant ) - Slant a given font given.

array imagepstext ( resource $image , string $text , resource $font , int $size , int $foreground , int $background , int $x , int $y [, int $space [, int $tightness [, float $angle [, int $antialias_steps ]]]] ) - Draws a text on an image using PostScript Type1 fonts.

bool imagerectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) - imagerectangle() creates a rectangle starting at the specified coordinates.

resource imagerotate ( resource $source_image , float $angle , int $bgd_color [, int $ignore_transparent ] ) - Rotates the source_image image using the given angle in degrees.

bool imagesavealpha ( resource $image , bool $saveflag ) - imagesavealpha() sets the flag to attempt to save full alpha channel information (as opposed to single-color transparency) when saving PNG images.

bool imagesetbrush ( resource $image , resource $brush ) -

bool imagesetpixel ( resource $image , int $x , int $y , int $color ) - imagesetpixel() draws a pixel at the specified coordinate.

bool imagesetstyle ( resource $image , array $style ) -

bool imagesetthickness ( resource $image , int $thickness ) - imagesetthickness() sets the thickness of the lines drawn when drawing rectangles, polygons, ellipses etc. etc. to thickness pixels.

bool imagesettile ( resource $image , resource $tile ) -

bool imagestring ( resource $image , int $font , int $x , int $y , string $string , int $color ) - Draws a string at the given coordinates.

bool imagestringup ( resource $image , int $font , int $x , int $y , string $string , int $color ) - Draws a string vertically at the given coordinates.

int imagesx ( resource $image ) - Returns the width of the given image resource.

int imagesy ( resource $image ) - Returns the height of the given image resource.

bool imagetruecolortopalette ( resource $image , bool $dither , int $ncolors ) - imagetruecolortopalette() converts a truecolor image to a palette image. The code for this function was originally drawn from the Independent JPEG Group library code, which is excellent. The code has been modified to preserve as much alpha channel information as possible in the resulting palette, in addition to preserving colors as well as possible. This does not work as well as might be hoped. It is usually best to simply produce a truecolor output image instead, which guarantees the highest output quality.

array imagettfbbox ( float $size , float $angle , string $fontfile , string $text ) - This function calculates and returns the bounding box in pixels for a TrueType text.

array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text ) - Writes the given text into the image using TrueType fonts.

int imagetypes ( void ) - Returns the image types supported by the current PHP installation.

bool imagewbmp ( resource $image [, string $filename [, int $foreground ]] ) -

bool imagexbm ( resource $image , string $filename [, int $foreground ] ) -

mixed iptcembed ( string $iptcdata , string $jpeg_file_name [, int $spool ] ) -

array iptcparse ( string $iptcblock ) -

bool jpeg2wbmp ( string $jpegname , string $wbmpname , int $dest_height , int $dest_width , int $threshold ) - Converts a JPEG file into a WBMP file.

bool png2wbmp ( string $pngname , string $wbmpname , int $dest_height , int $dest_width , int $threshold ) - Converts a PNG file into a WBMP file.