LinuxGuruz
Toll Free Numbers
Custom Search
MAIN MENU
Main Page
IT Jobs
IPTABLES
Linux Forum
HTML Forum
PHP Forum
MySQL Forum
Linux FAQ
Linux Articles
About Us
Privacy Policy

ADD TO FAVORITES


MARC

Mailing list ARChives
- Search by -
 Subjects
 Authors
 Bodies





FOLDOC

Computing Dictionary






Cheap UK Web Hosting Provider

Cheap Dedicated Servers UK

Cheap Linux VPS Hosting UK

Cheap Cloud Hosting UK



Icons
Icons


free brochure template
Free Brochure Template

Web Hosting

Domain Names

Web Design

Reseller Hosting

Registro de Dominios

Reseller Hosting


Toll Free Number for $2.00/Month!!!

Toll Free Number for $2.00/Month!!!
Creating images with GD and PHP

Title:       Creating images with GD and PHP
Contributor: Randall Goguen (aka Ranman)
Last Update: Tuesday July 18 22:37 EDT 2000


# First create a file that will build the image calling it submit.php

<?
if ($str == "Submit!") { $width = 68; $heigth = 20; }
else { $width = 86; $heigth = 20; }
Header("Content-type: image/gif");
$image  = ImageCreate($width,$heigth);
$light_blue = ImageColorAllocate($image,0,153,255);
$dark_blue = ImageColorAllocate($image,0,0,255);
imagestring($image,5,4,2,$str,$dark_blue);
ImageGif($image);
ImageDestroy($image);
?>


# Next create a test page calling it test.html

<?
if (!isset($set)) { $str = "Submit!"; }
else { $str = "Continue!"; }
$no_cashe = date("hi");
?>
<FORM ACTION="<? echo $PHP_SELF; ?>">
<INPUT TYPE="hidden" NAME="set" VALUE="1">
<CENTER>
<INPUT TYPE="image"
 SRC="submit.php?str=<? echo $str; ?>&<? echo $no_cashe; ?>"
 ALT="<? echo $str; ?>">
</CENTER>
</FORM>


# Lastly point your web browser at http://www.your.domain.com/test.html

Demo!
These functions are only available if PHP was configured with: --with-gd=/usr/local/gd1.3 Download and untar this file in the /usr/local directory: http://www.linuxguruz.org/downloads/gd1.3.tar.gz
cd /usr/local
tar -xvzf gd1.3.tar.gz
cd gd1.3
make all
# Then reconfigure PHP with --with-gd=/usr/local/gd1.3

# PHP Image functions.

array getimagesize(string imagefile [, array info])
  Get the size of an image as 4-element array

int imagearc(int im, int cx, int cy, int w, int h, int s, int e, int col)
  Draw a partial ellipse

int imagechar(int im, int font, int x, int y, string c, int col)
  Draw a character

int imagecharup(int im, int font, int x, int y, string c, int col)
  Draw a character rotated 90 degrees counter-clockwise

int imagecolorallocate(int im, int red, int green, int blue)
  Allocate a color for an image

int imagecolorat(int im, int x, int y)
  Get the index of the color of a pixel

int imagecolorclosest(int im, int red, int green, int blue)
  Get the index of the closest color to the specified color

int imagecolorclosesthwb(int im, int red, int green, int blue)
  Get the index of the color which has the hue, white and blackness
nearest to the given color

int imagecolordeallocate(int im, int index)
  De-allocate a color for an image

int imagecolorexact(int im, int red, int green, int blue)
  Get the index of the specified color

int imagecolorresolve(int im, int red, int green, int blue)
  Get the index of the specified color or its closest possible alternative

int imagecolorset(int im, int col, int red, int green, int blue)
  Set the color for the specified palette index

array imagecolorsforindex(int im, int col)
  Get the colors for an index

int imagecolorstotal(int im)
  Find out the number of colors in an image's palette

int imagecolortransparent(int im [, int col])
  Define a color as transparent

int imagecopy(int dst_im, int src_im, int dst_x, int
 dst_y, int src_x, int src_y, int src_w, int src_h)
  Copy part of an image

int imagecopymerge(int src_im, int dst_im, int dst_x, int
 dst_y, int src_x, int src_y, int src_w, int src_h, int pct)
  Merge one part of an image with another

int imagecopyresized(int dst_im, int src_im, int dst_x,
 int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h)
  Copy and resize part of an image

int imagecreate(int x_size, int y_size)
  Create a new image

int imagecreatefromgif(string filename)
  Create a new image from GIF file or URL

int imagecreatefromjpeg(string filename)
  Create a new image from JPEG file or URL

int imagecreatefrompng(string filename)
  Create a new image from PNG file or URL

int imagecreatefromwbmp(string filename)
  Create a new image from WBMP file or URL

int imagecreatefromxbm(string filename)
  Create a new image from XBM file or URL

int imagedashedline(int im, int x1, int y1, int x2, int y2, int col)
  Draw a dashed line

int imagedestroy(int im)
  Destroy an image

int imagefill(int im, int x, int y, int col)
  Flood fill

int imagefilledpolygon(int im, array point, int
 num_points, int col)
  Draw a filled polygon

int imagefilledrectangle(int im, int x1, int y1, int x2, int y2, int col)
  Draw a filled rectangle

int imagefilltoborder(int im, int x, int y, int border, int col)
  Flood fill to specific color

int imagefontheight(int font)
  Get font height

int imagefontwidth(int font)
  Get font width

int imagegammacorrect(int im, double inputgamma, double
 outputgamma)
  Apply a gamma correction to a GD image

int imagegif(int im [, string filename])
  Output GIF image to browser or file

int imageinterlace(int im [, int interlace])
  Enable or disable interlace

int imagejpeg(int im [, string filename [, int quality]])
  Output JPEG image to browser or file

int imageline(int im, int x1, int y1, int x2, int y2, int col)
  Draw a line

int imageloadfont(string filename)
  Load a new font

int imagepalettecopy(int dst, int src)
  Copy the palette from the src image onto the dst image

int imagepng(int im [, string filename])
  Output PNG image to browser or file

int imagepolygon(int im, array point, int num_points, int col)
  Draw a polygon

array imagepsbbox(string text, int font, int size [, int
 space, int tightness, int angle])
  Return the bounding box needed by a string if rasterized

bool imagepsencodefont(int font_index, string filename)
  To change a fonts character encoding vector

bool imagepsextendfont(int font_index, double extend)
  Extend or or condense (if extend < 1) a font

bool imagepsfreefont(int font_index)
  Free memory used by a font

int imagepsloadfont(string pathname)
  Load a new font from specified file

bool imagepsslantfont(int font_index, double slant)
  Slant a font

array imagepstext(int image, string text, int font, int size, int xcoord,
 int ycoord [, int space, int tightness, double angle, int antialias])
  Rasterize a string over an image

int imagerectangle(int im, int x1, int y1, int x2, int y2, int col)
  Draw a rectangle

int imagesetpixel(int im, int x, int y, int col)
  Set a single pixel

int imagestring(int im, int font, int x, int y, string str, int col)
  Draw a string horizontally

int imagestringup(int im, int font, int x, int y, string str, int col)
  Draw a string vertically - rotated 90 degrees counter-clockwise

int imagesx(int im)
  Get image width

int imagesy(int im)
  Get image height

array imagettfbbox(int size, int angle, string font_file, string text)
  Give the bounding box of a text using TrueType fonts

array imagettftext(int im, int size, int angle, int x,
 int y, int col, string font_file, string text)
  Write text to the image using a TrueType font

int imagetypes(void)
  Return the types of images supported in a bitfield - 1=gif, 2=jpeg, 4=png,
 8=wbmp

int imagewbmp(int im [, string filename])
  Output WBMP image to browser or file



        Anyone who wishes to make additions or changes to this
PHP Tip email them to webmaster@linuxguruz.org

        This document is Copyright (c) 1999, 2000 by LinuxGuruz

Return to the LinuxGuruz PHP Tutorials Page
Return to the LinuxGuruz Main Page


www.PHP.net Search Engine


Restrict the search to:
Copyright © 1999, 2000 The PHP Development Team.
Submit a PHP Tutorial

Title:

Contributor:

IRC NICK: (optional)

E-Mail Address: (optional)

Tutorial:

Return to the LinuxGuruz PHP Tutorials Page
Return to the LinuxGuruz Main Page

RESOURCE LINKS
Linux
Apache
HTML
PHP
MySQL
PostgreSQL
Oracle
CGI
Perl
Java
C/C++
Bash
Tcl
Networking
Security
ISP
IRC
Xwindow
Laptop
Graphics
Hardware
Reference
Misc

Broadband


filing cabinet

  • Buy Batteries for Laptops and Cameras
  • Notebooks
  • Michael Fertik
  • Reputation Defender

  • XP Style Icons
    XP Style Icons


    Network Certification


    Network Security


    Wireless Networking


    Canadian
    Web Hosting in Canada


    Drummer Portal


    Mending Media

    The Path Of
    Most Resistance


    Toll Free Number for $2.00/Month!!!

    Toll Free Number for $2.00/Month!!!


    Linux

    The Distributions





    Linux

    The Software





    Linux

    The News




    webmaster@linuxguruz.com
    Copyright © 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 and 2009 by LinuxGuruz