C to achieve the use of PHP extension Image_Tool image processing tool class
- 2020-04-01 21:35:38
- OfStack
One, class documentation
class Image_Tool{
function __construct($img_data="");
function annotate($txt, $opacity, $gravity, array $font);
function clean();
*
* Picture synthesis, can carry on the synthesis of many pictures, also can do the picture watermark
* @access public
* @param int $src_img The composite target image can be ImageTool Object or picture binary data
* @param int $x Compositing on canvas X coordinates
* @param string $y Compositing on canvas Y coordinates
* @return boolean
*
function composite($src_img, $x, $y);
function errmsg();
function errcode();
function exec($format, $display=false);
function flipH();
function flipV();
function getImageAttr();
function improve();
function resize($width, $height, $thumbnail=true);
function resizeRatio($ratio, $thumbnail=true);
function rotate($degree=90);
function setData($img_blob);
}
Third, the extended implementation
1. Php_fetch_url. H
/*
+----------------------------------------------------------------------+
| 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: |
+----------------------------------------------------------------------+
*/
#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
Source download address: (link: http://l9.yunpan.cn/lk/QEcqyYY6zy9YR)