I. Class Document Description
Copy codeThe Code is as follows: class Image_Tool {
/**
* Construct the Image_Tool object
* @ Param string | array $ img_data
* $ Img_data can be the image path
*/
Function _ construct ($ img_data = "");
/**
* Add text annotations or use them as text watermarks
* @ Access public
* @ Param string $ txt UTF8 encoded text
* @ Param float $ opacity sets transparency
* @ Param constant $ gravity
* Set the text placement position:
* NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast, Static
* @ Param array $ font the following attributes can be set for the font array:
* Name, constant, and font name. If you need to add a Chinese annotation, use a Chinese font. Otherwise, garbled characters are displayed.
* Supported fonts: SimSun (, default), SimKai (SimHei), SimHei (), MicroHei (micron black), and Arial
* Weight, font width, int
* Size, font size, int
* Color: Specifies the font color, for example, "blue", "# 0000ff", and "rgb (255,)". The default value is "black ";
* @ Return boolean
*/
Function annotate ($ txt, $ opacity, $ gravity, array $ font );
/**
* Reinitialize the data of an object to reuse one Image_Tool object multiple times.
* @ Access public
* @ Return void
*/
Function clean ();
*
* Image merging: You can merge multiple images or use them as image watermarks.
* @ Access public
* @ Param int $ src_img: The target image, which can be an ImageTool object or binary image data.
* @ Param int $ x the X coordinate of the merged canvas
* @ Param string $ y the Y coordinate of the merged canvas
* @ Return boolean
*
Function composite ($ src_img, $ x, $ y );
/**
* Error message returned
* @ Access public
* @ Return string
*/
Function errmsg ();
/**
* Error code returned
* @ Access public
* @ Return int
*/
Function errcode ();
/**
* Image Processing
* @ Access public
* @ Param string $ format
* @ Param boolean $ display
* @ Return boolean | if $ display is set to true, void is returned. Otherwise, binary data is returned. False is returned when a failure occurs.
*/
Function exec ($ format, $ display = false );
/**
* Horizontal flip
* @ Access public
* @ Return boolean
*/
Function flipH ();
/**
* Vertical flip
* @ Access public
* @ Return boolean
*/
Function flipV ();
/**
* Retrieving image attributes
* @ Access public
* @ Return array | boolean returns false if an error occurs.
*/
Function getImageAttr ();
/**
* Noise Removal to improve image quality, usually before exec
* @ Access public
* @ Return boolean
*/
Function improve ();
/**
* Proportional scaling is performed when only width or height is specified.
* @ Access public
* @ Param int $ width
* @ Param int $ height
* @ Param boolean $ thumbnail whether to clear additional Image Information
* @ Return boolean
*/
Function resize ($ width, $ height, $ thumbnail = true );
/**
* Scale proportionally. 1 is the original size
* @ Access public
* @ Param float $ ratio
* @ Param boolean $ thumbnail whether to clear additional Image Information
* @ Return boolean
*/
Function resizeRatio ($ ratio, $ thumbnail = true );
/**
* Rotate the image clockwise.
* @ Access public
* @ Param int $ degree rotation degree (0-360)
* @ Return boolean
*/
Function rotate ($ degree = 90 );
/**
* Set the binary data of the image to be processed
* @ Access public
* @ Param string $ img_blob
* @ Return boolean
*/
Function setData ($ img_blob );
}
Iii. Extension implementation
1. php_fetch_url.hCopy codeThe Code is as follows :/*
+ ---------------------------------------------------------------------- +
| PHP Version 5 |
+ ---------------------------------------------------------------------- +
| Copyright (c) 1997-2012 The PHP Group |
+ ---------------------------------------------------------------------- +
| This source file is subject to version 3.01 of the PHP license, |
| That is bundled with this package in the file LICENSE, and is |
| Available through the world-wide-web at the following url: |
| Http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| Obtain it through the world-wide-web, please send a note to |
| License@php.net so we can mail you a copy immediately. |
+ ---------------------------------------------------------------------- +
| Author: |
+ ---------------------------------------------------------------------- +
*/
/* $ Id $ */
# Ifndef PHP_IMAGE_TOOL_H
# Define PHP_IMAGE_TOOL_H
Extern zend_module_entry image_tool_module_entry;
# Define phpext_image_tool_ptr & image_tool_module_entry
# Ifdef PHP_WIN32
# Define PHP_IMAGE_TOOL_API _ declspec (dllexport)
# Elif defined (_ GNUC _) & _ GNUC _> = 4
# Define PHP_IMAGE_TOOL_API _ attribute _ (visibility ("default ")))
# Else
# Define PHP_IMAGE_TOOL_API
# Endif
# Ifdef ZTS
# Include "TSRM. h"
# Endif
# Define FETCH_THIS Z_OBJCE_P (getThis (), getThis ()
# Define IMAGETOOL_MAGICKWAND_RSRC_NAME "MagickWand"
# Define IMAGETOOL_PIXELWAND_RSRC_NAME "PixelWand"
# Define IMAGETOOL_NORTHWEST 1
# Define IMAGETOOL_NORTH 2
# Define IMAGETOOL_NORTHEAST 3
# Define IMAGETOOL_WEST 4
# Define IMAGETOOL_CENTER 5
# Define IMAGETOOL_EAST 6
# Define IMAGETOOL_SOUTHWEST 7
# Define IMAGETOOL_SOUTH 8
# Define IMAGETOOL_SOUTHEAST 9
# Define IMAGETOOL_STATIC 10
# Define IMAGETOOL_TOP_LEFT 1
# Define IMAGETOOL_TOP_CENTER 2
# Define IMAGETOOL_TOP_RIGHT 3
# Define IMAGETOOL_CENTER_LEFT 4
# Define IMAGETOOL_CENTER_CENTER 5
# Define IMAGETOOL_CENTER_RIGHT 6
# Define IMAGETOOL_BOTTOM_LEFT 7
# Define IMAGETOOL_BOTTOM_CENTER 8
# Define IMAGETOOL_BOTTOM_RIGHT 9
# Define GET_MAGICK_WAND (zval, magick_wand) zval = zend_read_property (FETCH_THIS, ZEND_STRL ("magick_wand"), 0 TSRMLS_CC );\
ZEND_FETCH_RESOURCE_NO_RETURN (magick_wand, MagickWand *, & zval,-1, IMAGETOOL_MAGICKWAND_RSRC_NAME, le_image_wand );
PHP_MINIT_FUNCTION (image_tool );
PHP_MSHUTDOWN_FUNCTION (image_tool );
PHP_RINIT_FUNCTION (image_tool );
PHP_RSHUTDOWN_FUNCTION (image_tool );
PHP_MINFO_FUNCTION (image_tool );
# Ifdef ZTS
# Define IMAGE_TOOL_G (v) TSRMG (image_tool_globals_id, zend_image_tool_globals *, v)
# Else
# Define IMAGE_TOOL_G (v) (image_tool_globals.v)
# Endif
# Endif/* PHP_IMAGE_TOOL_H */
Source code: http://l9.yunpan.cn/lk/QEcqyYY6zy9YR