Php Image Function

  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Php Image Function as PDF for free.

More details

  • Words: 951
  • Pages: 7
PHP IMAGE FUNCTION 1. Get image size Array GetImageSize(string filename); Key explains: Key 0: image width (pixels) Key 1: image height (pixels) Key 2: image type ( 1 = GIF, 2= JPG, 3= PNG) Key 3: return “height=XXX width=XXX” string > Array GetImageSize(string filename, array[imageinfo]); //read image marker info 2.

3.

Draw line Int ImageArc(int im, int cx, int cy, int w, int h, int s, int e, int col); (cx,cy): line center point. W, H: line width, line height. S, E: line start point, line end point.

Draw a horizontal char Int ImageChar(int im, int font, int x, int y, string c, int col); Font: font type (X, Y) : right above point 4. Draw a vertical char Int ImageCharUp(int im, int font, int x, int y, string c, int col); Font : font type

(X, Y) : right above point 5. Dispose image color Int ImageColorAllocate( int Im, int red, int green, int blue); Example 6.

Define transparent color Int ImageColorTransparent(int im, int [col]); Col is dispose of imagecolorallocate() function.

7.

Copy image part and resize the image Int ImageCopyResized(int dst_im, int src_im, int dstX, int dstY, Int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);

8. Create new image Int ImageCreate(int x_size, int y_size); Notes: it will return a pointer with image 9.

Create new image…. Int ImageCreateFromGIF(string filename||URL); Int ImageCreateFromJPEG(string filename||URL); Int ImageCreateFromPNG(); Int ImageCreateFromDF(); Int ImageCreateFromGD2(); Int ImageCreateFromGD2Part(); Int ImageCreateFromWBMP(); Int ImageCreateFromString(); Int ImageCreateFromXBM(); Int ImageCreateFromXPM();

10. Draw a dashed line Int ImageDashedLine(int im, int x1, int y1, int x2, int y2, int col); Draw dashed line from (x1, y1) to (x2, y2)

11. Free memory of image Int imagedestroy(int im); 12. Fill color Int imagefill(int im, int x, int y, int col); Fill (x, y) area with col(color) 13. Draw a polygon and fill color Int imagefilledpolugon(int im, array points, int num_points, int col); Points is a top point Points[0] = x0; Points[1] = y0; Points[2] = x1; Points[3] = y1; Num_points is a total top points If num_points =10, so points[0] ~ points[9] 14. Create a rectangle Int imagefilledrectangle(int im, int x1, int y1, int x2, int y2 int col); (x1, y1) = left top point (x2, y2) = right foot point 15. Fill border area color Int imagefilltoborder(int im, int x, int y, int border, int col)l Fill (x, y) area with col color 16. Get font height Int imagefontheight(int font); 17. Get font width Int imagefontwidth(int font); 18. Export image in browser or file Int imagegif(int im, string filename); Export in browser: imagegif(int im);

Notes: Please export MIME type header (“Content type: image/gif”) Another function: ImageGIF(), ImagePNG(), ImageJPEG(), ImageWBMP(), ImageGD(), ImageGD2() 19. Open and close interlace Int imageinterlace(int im, int [interlace]); Interlace =1 = open Interlace =0 = close 20. Draw a line Int imageline(int im, int x1, int y1, int x2, int y2, int col); Draw a line from (x1, y1) to (x2, y2) with col color 21. Load font Int imageloadfont( string file); Notes: only accept bimap font 22. Draw a polygon Int imagepolygon(int im, array points, int num_points, int col); Points is a top point Points[0] = x0; Points[1] = y0; Points[2] = x1; Points[3] = y1; Num_points is a total top points If num_points =10, so points[0] ~ points[9] 23. Draw a rectangle Int imagerectangle(int im, int x1, int y1, int x2, int y2, int col); 24. Draw a horizontal string Int imagestring(int im, int font, int x, int y, sting s, int col); 25. Draw a vertical string Int imagestringup(int im, int font, int x, int y, string s, int col); 26. Get image width

Int imagesx(int im); 27. Get image height Int imagesy(int im); 28. Calculate True Type font total area size Array imageTTFBBox(int size, int angle, string fontfile, string text); Text: calculate string Size: font size Angle: draw font degree Fontfile: TrueType font file name or path Array[num]: 6,7-----4,5 | | | | 0,1----- 2,3 Notes: use imageTTFBBox() function should install GD and FreeType library. 29. Draw TrueType font Array imageTTFText(int im, int size, int angle, int x, int y, int col, string fontfile, string text); Size : font size (x,y): start point Angle: draw font degree Fontfile: TrueType font file name and path Text: draw string Col: font color Array[num]: 6,7-----4,5 | | | | 0,1----- 2,3 Notes: use imageTTFBBox() function should install GD and FreeType library. Example
Header(“Content-type: image/gif”); $im = imagecreate(400, 30); $black = ImageColorAllocate($im, 0,0,0); $white = ImageColorAllocate($im, 255,255,255); ImageTTFText($im, 20, 0, 10, 20, $white, “text.gif”, “Testing…”); ImageGif($im); ImageDestroy($im); ?> 30. Get point color Int imagecolorat(int im, int x, int y); 31. Get color Int imagecolorclosest( int im, int red, int green, int blue); 32. Get color Int imagecolorexact(int im, int red, int green, int blue); Notes: if not this color, it will be return false. 33. Get color Int imagecolorresolve(int im, int red, int green, int blue); Notes: if not this color, it will be return resemble color. 34. Set color with index Bool imagecolorset(int im, int index, int red, int green, int blue); 35. Get color with index Array imagecolorsforindex(int im, int index); It will return associative array Array[“red”] Array[“green”] Array[“blue”] 36. Get total color in color tray Int imagecolorstotal(int im); 37. JPEG file change to WBMP file Int jpeg2wbmp(string jpegname, string wbmpname, int d_height,

Int d_width, int threshold); Anyother function: png2wbmp() Notes: Need PHP 4.0.5 version up and GD 1.8 version up.

Related Documents

Php Image Function
July 2020 1
Php Mysql Function
July 2020 4
Php Array Function
July 2020 1
Function
December 2019 67
Function
November 2019 54