SlideShare a Scribd company logo
Diploma in Web Engineering
Module IX: Using Extensions and
Image Manipulation
Rasan Samarasinghe
ESOFT Computer Studies (pvt) Ltd.
No 68/1, Main Street, Pallegama, Embilipitiya.
Contents
1. Image Manipulation with PHP
2. GD Library
3. ImageCreate()
4. ImageColorAllocate()
5. Drawing shapes and lines
6. imageellipse()
7. imagearc()
8. imagepolygon()
9. imagerectangle()
10. imageline()
11. Creating a new image
12. Using a Color Fill
13. imagefilledellipse()
14. imagefilledarc()
15. imagefilledpolygon()
16. imagefilledrectangle()
17. Basic Pie Chart
18. 3D Pie Chart
19. Modifying Existing Images
20. imagecreatefrompng()
21. imagecolortransparent()
22. imagecopymerge()
23. Creating a new image…
24. Stacking images…
25. Imagestring()
26. Draw a string
Image Manipulation with PHP
• PHP is not limited to creating just HTML output. It can
also be used to create and manipulate image files.
• You will need to compile PHP with the GD library for
this to work.
• GD and PHP may also require other libraries,
depending on which image formats you want to work
with.
GD Library
• The GD Graphics Library is a graphics software library
by Thomas Boutell for dynamically manipulating
images.
• GD stands for "Graphics Draw".
• GD can create images composed of lines, arcs, text,
other images, and multiple colors.
Drawing a new image - ImageCreate()
Returns an image identifier representing a blank
image of specified size.
resource imagecreate (int $width, int $height)
Define a color - ImageColorAllocate()
Returns a color identifier representing the color
composed of the given RGB components.
int imagecolorallocate (resource $image ,int $red
,int $green ,int $blue)
Creating Image
$myImage = imagecreate(250, 250);
$black = imagecolorallocate($myImage, 0, 0, 0);
header("Content-type: image/png"); // Send a Raw
HTTP Header
imagepng($myImage); // Outputs a PNG image
imagedestroy($myImage); // Destroy an image
Drawing shapes and lines
• imageellipse() - Draw an ellipse
• imagearc() - Draws an arc
• imagepolygon() - Draws a polygon
• imagerectangle() - Draw a rectangle
• imageline() - Draw a line
imageellipse() - Draw an ellipse
Draws an ellipse centered at the specified
coordinates.
bool imageellipse (resource $image, int $cx, int $cy,
int $width, int $height, int $color)
imagearc() - Draws an arc
Draws an arc of circle centered at the given
coordinates.
bool imagearc (resource $image, int $cx, int $cy, int
$width, int $height, int $start, int $end, int $color)
imagepolygon() - Draws a polygon
Creates a polygon in the given image.
bool imagepolygon (resource $image, array $points,
int $num_points, int $color)
imagerectangle() - Draw a rectangle
Creates a rectangle starting at the specified
coordinates.
bool imagerectangle (resource $image, int $x1, int
$y1, int $x2, int $y2, int $color)
imageline() - Draw a line
Draws a line between the two given points.
bool imageline (resource $image, int $x1, int $y1,
int $x2, int $y2, int $color)
Creating a new image
$myImage = imagecreate(250, 250);
$black = imagecolorallocate($myImage, 0, 0, 0);
$white = imagecolorallocate($myImage, 255, 255, 255);
$red = imagecolorallocate($myImage, 255, 0, 0);
$green = imagecolorallocate($myImage, 0, 255, 0);
$blue = imagecolorallocate($myImage, 0, 0, 255);
imagerectangle($myImage, 15, 15, 40, 55, $red);
imagerectangle($myImage, 40, 55, 165, 195, $white);
header("Content-type: image/png"); // Send a Raw HTTP Header
imagepng($myImage); // Outputs a PNG image
imagedestroy($myImage); // Destroy an image
Using a Color Fill
• imagefilledellipse() - Draw a filled ellipse
• imagefilledarc() - Draw a partial arc and fill it
• imagefilledpolygon() - Draw a filled polygon
• imagefilledrectangle() - Draw a filled rectangle
imagefilledellipse() - Draw a filled ellipse
Draws an ellipse centered at the specified
coordinate on the given image.
bool imagefilledellipse (resource $image, int $cx, int
$cy, int $width, int $height, int $color)
imagefilledarc() - Draw a partial arc and fill it
Draws a partial arc centered at the specified
coordinate in the given image.
bool imagefilledarc (resource $image, int $cx, int
$cy, int $width, int $height, int $start, int $end, int
$color, int $style)
imagefilledpolygon() - Draw a filled polygon
Creates a filled polygon in the given image.
bool imagefilledpolygon (resource $image, array
$points, int $num_points, int $color)
imagefilledrectangle() - Draw a filled rectangle
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 imagefilledrectangle (resource $image, int $x1,
int $y1, int $x2, int $y2, int $color)
Using a Color Fill
$myImage = imagecreate(150, 150);
$black = imagecolorallocate($myImage, 0, 0, 0);
$white = imagecolorallocate($myImage, 255, 255, 255);
$red = imagecolorallocate($myImage, 255, 0, 0);
$green = imagecolorallocate($myImage, 0, 255, 0);
$blue = imagecolorallocate($myImage, 0, 0, 255);
imagefilledrectangle($myImage, 15, 15, 40, 55, $red);
imagefilledrectangle($myImage, 40, 55, 65, 95, $white);
header("content-type: image/png");
imagepng($myImage);
imagedestroy($myImage);
Basic Pie Chart
$myImage = imagecreate(150, 150);
$white = imagecolorallocate($myImage, 255, 255, 255);
$red = imagecolorallocate($myImage, 255, 0, 0);
$green = imagecolorallocate($myImage, 0, 255, 0);
$blue = imagecolorallocate($myImage, 0, 0, 255);
imagefilledarc($myImage, 50, 50, 100, 100, 0, 90, $red, IMG_ARC_PIE);
imagefilledarc($myImage, 50, 50, 100, 100, 91, 180, $green, IMG_ARC_PIE);
imagefilledarc($myImage, 50, 50, 100, 100, 181, 360, $blue, IMG_ARC_PIE);
header("Content-type: image/png");
imagepng($myImage);
imagedestroy($myImage);
3D Pie Chart
$myImage = imagecreate(150, 150);
$white = imagecolorallocate($myImage, 255, 255, 255);
$red = imagecolorallocate($myImage, 255, 0, 0);
$green = imagecolorallocate($myImage, 0, 255, 0);
$blue = imagecolorallocate($myImage, 0, 0, 255);
$lt_red = imagecolorallocate($myImage, 255, 150, 150);
$lt_green = imagecolorallocate($myImage, 150, 255, 150);
$lt_blue = imagecolorallocate($myImage, 150, 150, 255);
for($i = 60; $i > 50; $i--){
imagefilledarc($myImage, 50, $i, 100, 50, 0, 90, $lt_red, IMG_ARC_PIE);
imagefilledarc($myImage, 50, $i, 100, 50, 91, 180, $lt_green, IMG_ARC_PIE);
imagefilledarc($myImage, 50, $i, 100, 50, 181, 360, $lt_blue, IMG_ARC_PIE);
}
imagefilledarc($myImage, 50, $i, 100, 50, 0, 90, $red, IMG_ARC_PIE);
imagefilledarc($myImage, 50, $i, 100, 50, 91, 180, $green, IMG_ARC_PIE);
imagefilledarc($myImage, 50, $i, 100, 50, 181, 360, $blue, IMG_ARC_PIE);
header("Content-type: image/png");
imagepng($myImage);
imagedestroy($myImage);
Modifying Existing Images
• imagecreatefrompng() - Create a new image from
file or URL
• imagecolortransparent() - Define a color as
transparent
• imagecopymerge() - Copy and merge part of an
image
imagecreatefrompng()
Returns an image identifier representing the image
obtained from the given filename.
resource imagecreatefrompng (string $filename)
imagecolortransparent()
Sets the transparent color in the given image.
int imagecolortransparent (resource $image [, int
$color ])
imagecopymerge()
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)
Creating a new image from existing image
$myImage = imagecreatefrompng("img1.png");
$white = imagecolorallocate($myImage, 255, 255, 255);
imagefilledellipse($myImage, 55, 170, 50, 20, $white);
imagefilledellipse($myImage, 150, 70, 20, 20, $white);
imagefilledellipse($myImage, 125, 70, 20, 20, $white);
header("Content-type: image/png");
imagepng($myImage);
imagedestroy($myImage);
Stacking images and making them transparent
$baseimage = imagecreatefrompng("img1.png");
for($i=2; $i<5; $i++){
$myImage = imagecreatefrompng("img".$i.".png");
$gray = imagecolorallocate($myImage, 5, 5, 5);
imagecolortransparent($myImage, $gray);
imagecopymerge($baseimage, $myImage, 10, 10, 0, 0, 250,
250, 60);
}
header("Content-type: image/png");
imagepng($baseimage);
imagedestroy($baseimage);
Imagestring() - Draw a string horizontally
Draws a string at the given coordinates.
bool imagestring (resource $image, int $font, int $x,
int $y, string $string, int $color)
Draw a string
$myImage = imagecreate(400, 300);
$background = imagecolorallocate($myImage, 200, 10, 10);
$text = imagecolorallocate($myImage, 20, 200, 20);
imagestring($myImage, 5, 10, 20, "Hello World", $text);
header("Content-type: image/png");
imagepng($myImage);
imagedestroy($myImage);
The End
http://twitter.com/rasansmn
Ad

More Related Content

What's hot (7)

Digital Image Processing (Lab 06)
Digital Image Processing (Lab 06)Digital Image Processing (Lab 06)
Digital Image Processing (Lab 06)
Moe Moe Myint
 
Vcs17
Vcs17Vcs17
Vcs17
Malikireddy Bramhananda Reddy
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
Gary Yeh
 
Intro to HTML5 Canvas
Intro to HTML5 CanvasIntro to HTML5 Canvas
Intro to HTML5 Canvas
Juho Vepsäläinen
 
R graphics by Novi Reandy Sasmita
R graphics by Novi Reandy SasmitaR graphics by Novi Reandy Sasmita
R graphics by Novi Reandy Sasmita
beasiswa
 
Foliumcheatsheet
FoliumcheatsheetFoliumcheatsheet
Foliumcheatsheet
Nishant Upadhyay
 
Beyond Scala Lens
Beyond Scala LensBeyond Scala Lens
Beyond Scala Lens
Julien Truffaut
 

Viewers also liked (20)

DIWE - File handling with PHP
DIWE - File handling with PHPDIWE - File handling with PHP
DIWE - File handling with PHP
Rasan Samarasinghe
 
DIWE - Working with MySQL Databases
DIWE - Working with MySQL DatabasesDIWE - Working with MySQL Databases
DIWE - Working with MySQL Databases
Rasan Samarasinghe
 
DIWE - Fundamentals of PHP
DIWE - Fundamentals of PHPDIWE - Fundamentals of PHP
DIWE - Fundamentals of PHP
Rasan Samarasinghe
 
DIWE - Advanced PHP Concepts
DIWE - Advanced PHP ConceptsDIWE - Advanced PHP Concepts
DIWE - Advanced PHP Concepts
Rasan Samarasinghe
 
DIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningDIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web Designing
Rasan Samarasinghe
 
Toolbarexample
ToolbarexampleToolbarexample
Toolbarexample
yugandhar vadlamudi
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
Garuda Trainings
 
Exception handling in java
Exception handling in java Exception handling in java
Exception handling in java
yugandhar vadlamudi
 
Yaazli International Spring Training
Yaazli International Spring Training Yaazli International Spring Training
Yaazli International Spring Training
Arjun Sridhar U R
 
Yaazli International Hibernate Training
Yaazli International Hibernate TrainingYaazli International Hibernate Training
Yaazli International Hibernate Training
Arjun Sridhar U R
 
For Loops and Variables in Java
For Loops and Variables in JavaFor Loops and Variables in Java
For Loops and Variables in Java
Pokequesthero
 
Yaazli International Web Project Workshop
Yaazli International Web Project WorkshopYaazli International Web Project Workshop
Yaazli International Web Project Workshop
Arjun Sridhar U R
 
Savr
SavrSavr
Savr
Shahar Barsheshet
 
Core java online training
Core java online trainingCore java online training
Core java online training
Glory IT Technologies Pvt. Ltd.
 
09events
09events09events
09events
Waheed Warraich
 
02basics
02basics02basics
02basics
Waheed Warraich
 
Yaazli International AngularJS 5 Training
Yaazli International AngularJS 5 TrainingYaazli International AngularJS 5 Training
Yaazli International AngularJS 5 Training
Arjun Sridhar U R
 
Java quick reference v2
Java quick reference v2Java quick reference v2
Java quick reference v2
Christopher Akinlade
 
Non ieee dot net projects list
Non  ieee dot net projects list Non  ieee dot net projects list
Non ieee dot net projects list
Mumbai Academisc
 
Singleton pattern
Singleton patternSingleton pattern
Singleton pattern
yugandhar vadlamudi
 
Ad

Similar to DIWE - Using Extensions and Image Manipulation (20)

openFrameworks 007 - graphics
openFrameworks 007 - graphicsopenFrameworks 007 - graphics
openFrameworks 007 - graphics
roxlu
 
Drawing images
Drawing imagesDrawing images
Drawing images
MfahamedaThabaseem
 
Help me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdfHelp me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdf
fedosys
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdf
UmarMustafa13
 
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Chris Adamson
 
HTML 5_Canvas
HTML 5_CanvasHTML 5_Canvas
HTML 5_Canvas
Vishakha Vaidya
 
PYTHON-OPEEEEEEEEEEEEEEN-CV (1) kgjkg.pptx
PYTHON-OPEEEEEEEEEEEEEEN-CV (1) kgjkg.pptxPYTHON-OPEEEEEEEEEEEEEEN-CV (1) kgjkg.pptx
PYTHON-OPEEEEEEEEEEEEEEN-CV (1) kgjkg.pptx
CharimaineMarquez2
 
PYTHON-OOOOOOOOOOPPPPPPEEEEEEEEN-CV.pptx
PYTHON-OOOOOOOOOOPPPPPPEEEEEEEEN-CV.pptxPYTHON-OOOOOOOOOOPPPPPPEEEEEEEEN-CV.pptx
PYTHON-OOOOOOOOOOPPPPPPEEEEEEEEN-CV.pptx
CharimaineMarquez2
 
Creating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfCreating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdf
ShaiAlmog1
 
Basics of image processing using MATLAB
Basics of image processing using MATLABBasics of image processing using MATLAB
Basics of image processing using MATLAB
Mohsin Siddique
 
Resize image vb.net
Resize image vb.netResize image vb.net
Resize image vb.net
Hotland Sitorus
 
Lecture 2.pptx
Lecture 2.pptxLecture 2.pptx
Lecture 2.pptx
cpen19111030KFUEIT
 
Displaying information within a window.68
Displaying information within a window.68Displaying information within a window.68
Displaying information within a window.68
myrajendra
 
Introduction to Image Processing with MATLAB
Introduction to Image Processing with MATLABIntroduction to Image Processing with MATLAB
Introduction to Image Processing with MATLAB
Sriram Emarose
 
A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processing
Chu Lam
 
Histogram of Image Colors
Histogram of Image ColorsHistogram of Image Colors
Histogram of Image Colors
pythontic
 
Computer vision labs for improving in the subject
Computer vision labs for improving in the subjectComputer vision labs for improving in the subject
Computer vision labs for improving in the subject
kkmma283
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfbfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
shehabhamad_90
 
Open CV library In Python_Vahid ebrahimian.pptx
Open CV library In Python_Vahid ebrahimian.pptxOpen CV library In Python_Vahid ebrahimian.pptx
Open CV library In Python_Vahid ebrahimian.pptx
vahid67ebrahimian
 
Intro to computer vision in .net
Intro to computer vision in .netIntro to computer vision in .net
Intro to computer vision in .net
Stephen Lorello
 
openFrameworks 007 - graphics
openFrameworks 007 - graphicsopenFrameworks 007 - graphics
openFrameworks 007 - graphics
roxlu
 
Help me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdfHelp me fix the error shown above in my code of image.cpp please~I.pdf
Help me fix the error shown above in my code of image.cpp please~I.pdf
fedosys
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdf
UmarMustafa13
 
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Core Image: The Most Fun API You're Not Using, CocoaConf Atlanta, December 2014
Chris Adamson
 
PYTHON-OPEEEEEEEEEEEEEEN-CV (1) kgjkg.pptx
PYTHON-OPEEEEEEEEEEEEEEN-CV (1) kgjkg.pptxPYTHON-OPEEEEEEEEEEEEEEN-CV (1) kgjkg.pptx
PYTHON-OPEEEEEEEEEEEEEEN-CV (1) kgjkg.pptx
CharimaineMarquez2
 
PYTHON-OOOOOOOOOOPPPPPPEEEEEEEEN-CV.pptx
PYTHON-OOOOOOOOOOPPPPPPEEEEEEEEN-CV.pptxPYTHON-OOOOOOOOOOPPPPPPEEEEEEEEN-CV.pptx
PYTHON-OOOOOOOOOOPPPPPPEEEEEEEEN-CV.pptx
CharimaineMarquez2
 
Creating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfCreating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdf
ShaiAlmog1
 
Basics of image processing using MATLAB
Basics of image processing using MATLABBasics of image processing using MATLAB
Basics of image processing using MATLAB
Mohsin Siddique
 
Displaying information within a window.68
Displaying information within a window.68Displaying information within a window.68
Displaying information within a window.68
myrajendra
 
Introduction to Image Processing with MATLAB
Introduction to Image Processing with MATLABIntroduction to Image Processing with MATLAB
Introduction to Image Processing with MATLAB
Sriram Emarose
 
A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processing
Chu Lam
 
Histogram of Image Colors
Histogram of Image ColorsHistogram of Image Colors
Histogram of Image Colors
pythontic
 
Computer vision labs for improving in the subject
Computer vision labs for improving in the subjectComputer vision labs for improving in the subject
Computer vision labs for improving in the subject
kkmma283
 
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdfbfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
bfd23fd7-0d89-45c0-8b82-c991b30ed375.pdf
shehabhamad_90
 
Open CV library In Python_Vahid ebrahimian.pptx
Open CV library In Python_Vahid ebrahimian.pptxOpen CV library In Python_Vahid ebrahimian.pptx
Open CV library In Python_Vahid ebrahimian.pptx
vahid67ebrahimian
 
Intro to computer vision in .net
Intro to computer vision in .netIntro to computer vision in .net
Intro to computer vision in .net
Stephen Lorello
 
Ad

More from Rasan Samarasinghe (20)

Managing the under performance in projects.pptx
Managing the under performance in projects.pptxManaging the under performance in projects.pptx
Managing the under performance in projects.pptx
Rasan Samarasinghe
 
Agile project management with scrum
Agile project management with scrumAgile project management with scrum
Agile project management with scrum
Rasan Samarasinghe
 
Introduction to Agile
Introduction to AgileIntroduction to Agile
Introduction to Agile
Rasan Samarasinghe
 
IT Introduction (en)
IT Introduction (en)IT Introduction (en)
IT Introduction (en)
Rasan Samarasinghe
 
Application of Unified Modelling Language
Application of Unified Modelling LanguageApplication of Unified Modelling Language
Application of Unified Modelling Language
Rasan Samarasinghe
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST API
Rasan Samarasinghe
 
Advanced Web Development in PHP - Understanding Project Development Methodolo...
Advanced Web Development in PHP - Understanding Project Development Methodolo...Advanced Web Development in PHP - Understanding Project Development Methodolo...
Advanced Web Development in PHP - Understanding Project Development Methodolo...
Rasan Samarasinghe
 
Advanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitAdvanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with Git
Rasan Samarasinghe
 
DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScript
Rasan Samarasinghe
 
DIWE - Multimedia Technologies
DIWE - Multimedia TechnologiesDIWE - Multimedia Technologies
DIWE - Multimedia Technologies
Rasan Samarasinghe
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
Rasan Samarasinghe
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
 
Esoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsEsoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basics
Rasan Samarasinghe
 
DISE - Software Testing and Quality Management
DISE - Software Testing and Quality ManagementDISE - Software Testing and Quality Management
DISE - Software Testing and Quality Management
Rasan Samarasinghe
 
DISE - Introduction to Project Management
DISE - Introduction to Project ManagementDISE - Introduction to Project Management
DISE - Introduction to Project Management
Rasan Samarasinghe
 
DISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in JavaDISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in Java
Rasan Samarasinghe
 
DISE - Windows Based Application Development in C#
DISE - Windows Based Application Development in C#DISE - Windows Based Application Development in C#
DISE - Windows Based Application Development in C#
Rasan Samarasinghe
 
DISE - Database Concepts
DISE - Database ConceptsDISE - Database Concepts
DISE - Database Concepts
Rasan Samarasinghe
 
DISE - OOAD Using UML
DISE - OOAD Using UMLDISE - OOAD Using UML
DISE - OOAD Using UML
Rasan Samarasinghe
 
DISE - Programming Concepts
DISE - Programming ConceptsDISE - Programming Concepts
DISE - Programming Concepts
Rasan Samarasinghe
 
Managing the under performance in projects.pptx
Managing the under performance in projects.pptxManaging the under performance in projects.pptx
Managing the under performance in projects.pptx
Rasan Samarasinghe
 
Agile project management with scrum
Agile project management with scrumAgile project management with scrum
Agile project management with scrum
Rasan Samarasinghe
 
Application of Unified Modelling Language
Application of Unified Modelling LanguageApplication of Unified Modelling Language
Application of Unified Modelling Language
Rasan Samarasinghe
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST API
Rasan Samarasinghe
 
Advanced Web Development in PHP - Understanding Project Development Methodolo...
Advanced Web Development in PHP - Understanding Project Development Methodolo...Advanced Web Development in PHP - Understanding Project Development Methodolo...
Advanced Web Development in PHP - Understanding Project Development Methodolo...
Rasan Samarasinghe
 
Advanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with GitAdvanced Web Development in PHP - Code Versioning and Branching with Git
Advanced Web Development in PHP - Code Versioning and Branching with Git
Rasan Samarasinghe
 
DIWE - Programming with JavaScript
DIWE - Programming with JavaScriptDIWE - Programming with JavaScript
DIWE - Programming with JavaScript
Rasan Samarasinghe
 
DIWE - Multimedia Technologies
DIWE - Multimedia TechnologiesDIWE - Multimedia Technologies
DIWE - Multimedia Technologies
Rasan Samarasinghe
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
Rasan Samarasinghe
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
 
Esoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basicsEsoft Metro Campus - Certificate in java basics
Esoft Metro Campus - Certificate in java basics
Rasan Samarasinghe
 
DISE - Software Testing and Quality Management
DISE - Software Testing and Quality ManagementDISE - Software Testing and Quality Management
DISE - Software Testing and Quality Management
Rasan Samarasinghe
 
DISE - Introduction to Project Management
DISE - Introduction to Project ManagementDISE - Introduction to Project Management
DISE - Introduction to Project Management
Rasan Samarasinghe
 
DISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in JavaDISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in Java
Rasan Samarasinghe
 
DISE - Windows Based Application Development in C#
DISE - Windows Based Application Development in C#DISE - Windows Based Application Development in C#
DISE - Windows Based Application Development in C#
Rasan Samarasinghe
 

Recently uploaded (20)

"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 

DIWE - Using Extensions and Image Manipulation

  • 1. Diploma in Web Engineering Module IX: Using Extensions and Image Manipulation Rasan Samarasinghe ESOFT Computer Studies (pvt) Ltd. No 68/1, Main Street, Pallegama, Embilipitiya.
  • 2. Contents 1. Image Manipulation with PHP 2. GD Library 3. ImageCreate() 4. ImageColorAllocate() 5. Drawing shapes and lines 6. imageellipse() 7. imagearc() 8. imagepolygon() 9. imagerectangle() 10. imageline() 11. Creating a new image 12. Using a Color Fill 13. imagefilledellipse() 14. imagefilledarc() 15. imagefilledpolygon() 16. imagefilledrectangle() 17. Basic Pie Chart 18. 3D Pie Chart 19. Modifying Existing Images 20. imagecreatefrompng() 21. imagecolortransparent() 22. imagecopymerge() 23. Creating a new image… 24. Stacking images… 25. Imagestring() 26. Draw a string
  • 3. Image Manipulation with PHP • PHP is not limited to creating just HTML output. It can also be used to create and manipulate image files. • You will need to compile PHP with the GD library for this to work. • GD and PHP may also require other libraries, depending on which image formats you want to work with.
  • 4. GD Library • The GD Graphics Library is a graphics software library by Thomas Boutell for dynamically manipulating images. • GD stands for "Graphics Draw". • GD can create images composed of lines, arcs, text, other images, and multiple colors.
  • 5. Drawing a new image - ImageCreate() Returns an image identifier representing a blank image of specified size. resource imagecreate (int $width, int $height)
  • 6. Define a color - ImageColorAllocate() Returns a color identifier representing the color composed of the given RGB components. int imagecolorallocate (resource $image ,int $red ,int $green ,int $blue)
  • 7. Creating Image $myImage = imagecreate(250, 250); $black = imagecolorallocate($myImage, 0, 0, 0); header("Content-type: image/png"); // Send a Raw HTTP Header imagepng($myImage); // Outputs a PNG image imagedestroy($myImage); // Destroy an image
  • 8. Drawing shapes and lines • imageellipse() - Draw an ellipse • imagearc() - Draws an arc • imagepolygon() - Draws a polygon • imagerectangle() - Draw a rectangle • imageline() - Draw a line
  • 9. imageellipse() - Draw an ellipse Draws an ellipse centered at the specified coordinates. bool imageellipse (resource $image, int $cx, int $cy, int $width, int $height, int $color)
  • 10. imagearc() - Draws an arc Draws an arc of circle centered at the given coordinates. bool imagearc (resource $image, int $cx, int $cy, int $width, int $height, int $start, int $end, int $color)
  • 11. imagepolygon() - Draws a polygon Creates a polygon in the given image. bool imagepolygon (resource $image, array $points, int $num_points, int $color)
  • 12. imagerectangle() - Draw a rectangle Creates a rectangle starting at the specified coordinates. bool imagerectangle (resource $image, int $x1, int $y1, int $x2, int $y2, int $color)
  • 13. imageline() - Draw a line Draws a line between the two given points. bool imageline (resource $image, int $x1, int $y1, int $x2, int $y2, int $color)
  • 14. Creating a new image $myImage = imagecreate(250, 250); $black = imagecolorallocate($myImage, 0, 0, 0); $white = imagecolorallocate($myImage, 255, 255, 255); $red = imagecolorallocate($myImage, 255, 0, 0); $green = imagecolorallocate($myImage, 0, 255, 0); $blue = imagecolorallocate($myImage, 0, 0, 255); imagerectangle($myImage, 15, 15, 40, 55, $red); imagerectangle($myImage, 40, 55, 165, 195, $white); header("Content-type: image/png"); // Send a Raw HTTP Header imagepng($myImage); // Outputs a PNG image imagedestroy($myImage); // Destroy an image
  • 15. Using a Color Fill • imagefilledellipse() - Draw a filled ellipse • imagefilledarc() - Draw a partial arc and fill it • imagefilledpolygon() - Draw a filled polygon • imagefilledrectangle() - Draw a filled rectangle
  • 16. imagefilledellipse() - Draw a filled ellipse Draws an ellipse centered at the specified coordinate on the given image. bool imagefilledellipse (resource $image, int $cx, int $cy, int $width, int $height, int $color)
  • 17. imagefilledarc() - Draw a partial arc and fill it Draws a partial arc centered at the specified coordinate in the given image. bool imagefilledarc (resource $image, int $cx, int $cy, int $width, int $height, int $start, int $end, int $color, int $style)
  • 18. imagefilledpolygon() - Draw a filled polygon Creates a filled polygon in the given image. bool imagefilledpolygon (resource $image, array $points, int $num_points, int $color)
  • 19. imagefilledrectangle() - Draw a filled rectangle 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 imagefilledrectangle (resource $image, int $x1, int $y1, int $x2, int $y2, int $color)
  • 20. Using a Color Fill $myImage = imagecreate(150, 150); $black = imagecolorallocate($myImage, 0, 0, 0); $white = imagecolorallocate($myImage, 255, 255, 255); $red = imagecolorallocate($myImage, 255, 0, 0); $green = imagecolorallocate($myImage, 0, 255, 0); $blue = imagecolorallocate($myImage, 0, 0, 255); imagefilledrectangle($myImage, 15, 15, 40, 55, $red); imagefilledrectangle($myImage, 40, 55, 65, 95, $white); header("content-type: image/png"); imagepng($myImage); imagedestroy($myImage);
  • 21. Basic Pie Chart $myImage = imagecreate(150, 150); $white = imagecolorallocate($myImage, 255, 255, 255); $red = imagecolorallocate($myImage, 255, 0, 0); $green = imagecolorallocate($myImage, 0, 255, 0); $blue = imagecolorallocate($myImage, 0, 0, 255); imagefilledarc($myImage, 50, 50, 100, 100, 0, 90, $red, IMG_ARC_PIE); imagefilledarc($myImage, 50, 50, 100, 100, 91, 180, $green, IMG_ARC_PIE); imagefilledarc($myImage, 50, 50, 100, 100, 181, 360, $blue, IMG_ARC_PIE); header("Content-type: image/png"); imagepng($myImage); imagedestroy($myImage);
  • 22. 3D Pie Chart $myImage = imagecreate(150, 150); $white = imagecolorallocate($myImage, 255, 255, 255); $red = imagecolorallocate($myImage, 255, 0, 0); $green = imagecolorallocate($myImage, 0, 255, 0); $blue = imagecolorallocate($myImage, 0, 0, 255); $lt_red = imagecolorallocate($myImage, 255, 150, 150); $lt_green = imagecolorallocate($myImage, 150, 255, 150); $lt_blue = imagecolorallocate($myImage, 150, 150, 255); for($i = 60; $i > 50; $i--){ imagefilledarc($myImage, 50, $i, 100, 50, 0, 90, $lt_red, IMG_ARC_PIE); imagefilledarc($myImage, 50, $i, 100, 50, 91, 180, $lt_green, IMG_ARC_PIE); imagefilledarc($myImage, 50, $i, 100, 50, 181, 360, $lt_blue, IMG_ARC_PIE); } imagefilledarc($myImage, 50, $i, 100, 50, 0, 90, $red, IMG_ARC_PIE); imagefilledarc($myImage, 50, $i, 100, 50, 91, 180, $green, IMG_ARC_PIE); imagefilledarc($myImage, 50, $i, 100, 50, 181, 360, $blue, IMG_ARC_PIE); header("Content-type: image/png"); imagepng($myImage); imagedestroy($myImage);
  • 23. Modifying Existing Images • imagecreatefrompng() - Create a new image from file or URL • imagecolortransparent() - Define a color as transparent • imagecopymerge() - Copy and merge part of an image
  • 24. imagecreatefrompng() Returns an image identifier representing the image obtained from the given filename. resource imagecreatefrompng (string $filename)
  • 25. imagecolortransparent() Sets the transparent color in the given image. int imagecolortransparent (resource $image [, int $color ])
  • 26. imagecopymerge() 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)
  • 27. Creating a new image from existing image $myImage = imagecreatefrompng("img1.png"); $white = imagecolorallocate($myImage, 255, 255, 255); imagefilledellipse($myImage, 55, 170, 50, 20, $white); imagefilledellipse($myImage, 150, 70, 20, 20, $white); imagefilledellipse($myImage, 125, 70, 20, 20, $white); header("Content-type: image/png"); imagepng($myImage); imagedestroy($myImage);
  • 28. Stacking images and making them transparent $baseimage = imagecreatefrompng("img1.png"); for($i=2; $i<5; $i++){ $myImage = imagecreatefrompng("img".$i.".png"); $gray = imagecolorallocate($myImage, 5, 5, 5); imagecolortransparent($myImage, $gray); imagecopymerge($baseimage, $myImage, 10, 10, 0, 0, 250, 250, 60); } header("Content-type: image/png"); imagepng($baseimage); imagedestroy($baseimage);
  • 29. Imagestring() - Draw a string horizontally Draws a string at the given coordinates. bool imagestring (resource $image, int $font, int $x, int $y, string $string, int $color)
  • 30. Draw a string $myImage = imagecreate(400, 300); $background = imagecolorallocate($myImage, 200, 10, 10); $text = imagecolorallocate($myImage, 20, 200, 20); imagestring($myImage, 5, 10, 20, "Hello World", $text); header("Content-type: image/png"); imagepng($myImage); imagedestroy($myImage);

Editor's Notes

  • #15: imagejpeg — Output jpeg image to browser or file imagegif — Output gif image to browser or file
  • #17: image An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(). cx x-coordinate of the center. cy y-coordinate of the center. width The ellipse width. height The ellipse height. color The fill color. A color identifier created with imagecolorallocate().
  • #18: image An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(). cx x-coordinate of the center. cy y-coordinate of the center. width The arc width. height The arc height. start The arc start angle, in degrees. end The arc end angle, in degrees. 0° is located at the three-o'clock position, and the arc is drawn clockwise. color A color identifier created with imagecolorallocate(). style A bitwise OR of the following possibilities: IMG_ARC_PIE IMG_ARC_CHORD IMG_ARC_NOFILL IMG_ARC_EDGED
  • #19: imagefilledpolygon($myImage,array(20,20,40, 20,20,60),3,$red); image An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(). points An array containing the x and y coordinates of the polygons vertices consecutively. num_points Total number of vertices, which must be at least 3. color A color identifier created with imagecolorallocate().
  • #20: image An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(). x1 x-coordinate for point 1. y1 y-coordinate for point 1. x2 x-coordinate for point 2. y2 y-coordinate for point 2. color The fill color. A color identifier created with imagecolorallocate().