/* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.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. | +----------------------------------------------------------------------+ | Original author: Matt McClanahan | | Current maintainer: Piotr Pawlow | +----------------------------------------------------------------------+ */ #include "php.h" #include "php_ini.h" #include "php_imlib.h" #include "php_globals.h" #include "php_open_temporary_file.h" #include "ext/standard/info.h" /* #define IMLIB_DEBUG */ #ifdef IMLIB_DEBUG #define ID_PRINTF(format, args...) \ fprintf(stderr, "php-imlib: " format "\n" , ## args); fflush(stdout) #endif #if HAVE_IMLIB #ifdef ZTS int gd_imlib_id; #else zend_imlib_globals imlib_globals; #endif ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_add_color_to_color_range, 0, 6, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, cr, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_blend_image_onto_image, 0, 14, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, dstimg, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, srcimg, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, malpha, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, srcx, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, srcy, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, srcw, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, srch, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, dstx, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, dsty, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, dstw, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, dsth, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, dither, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, blend, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, alias, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_clone_image, 0, 1, MAY_BE_RESOURCE|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_create_color_range, 0, 0, MAY_BE_RESOURCE|MAY_BE_NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_create_color_modifier, 0, 0, MAY_BE_RESOURCE|MAY_BE_FALSE|MAY_BE_NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_create_cropped_image, 0, 5, MAY_BE_RESOURCE|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, sx, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, sy, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, sw, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, sh, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_create_cropped_scaled_image, 0, 7, MAY_BE_RESOURCE|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, sx, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, sy, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, sw, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, sh, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, dw, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, dh, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_create_image, 0, 2, MAY_BE_RESOURCE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_create_rotated_image, 0, 2, MAY_BE_RESOURCE|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, srcimg, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, degrees, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, radians, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_create_scaled_image, 0, 3, MAY_BE_RESOURCE|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, dstw, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, dsth, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_dump_image, 0, 1, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(1, err, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, quality, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_free_color_range, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, cr, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_free_color_modifier, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, cm, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_free_font, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, font, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_free_image, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_get_text_size, 0, 5, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, font, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_ARG_TYPE_INFO(1, w, IS_LONG, 0) ZEND_ARG_TYPE_INFO(1, h, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, direction, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_get_text_advance, 0, 5, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, font, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_ARG_TYPE_INFO(1, horiz_adv, IS_LONG, 0) ZEND_ARG_TYPE_INFO(1, vert_adv, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, direction, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_blur, 0, 2, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, radius, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_draw_ellipse, 0, 9, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, xc, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, yc, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, cliprect, IS_ARRAY, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_draw_line, 0, 9, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, x1, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y1, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, x2, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y2, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, cliprect, IS_ARRAY, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_draw_polygon, 0, 7, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, polygon, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, closed, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, cliprect, IS_ARRAY, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_draw_rectangle, 0, 9, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, cliprect, IS_ARRAY, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_fill_color_range_rectangle, 0, 7, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, cr, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, width, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, height, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, angle, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, cliprect, IS_ARRAY, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_fill_ellipse, 0, 9, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, xc, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, yc, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, cliprect, IS_ARRAY, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_fill_polygon, 0, 6, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, polygon, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, cliprect, IS_ARRAY, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_fill_rectangle, 0, 9, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, cliprect, IS_ARRAY, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_flip_horizontal, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_flip_vertical, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_flip_diagonal, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_orientate, 0, 2, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, stepping, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_format, 0, 1, MAY_BE_STRING|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_get_filename, 0, 1, MAY_BE_STRING|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_get_height, 0, 1, MAY_BE_LONG|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_get_width, 0, 1, MAY_BE_LONG|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_has_alpha, 0, 1, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_modify_alpha, 0, 2, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, alpha, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_sharpen, 0, 2, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, radius, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_set_format, 0, 2, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_tile_horizontal, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_tile_vertical, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_tile, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_list_fonts, 0, 0, MAY_BE_ARRAY|MAY_BE_FALSE|MAY_BE_NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_load_font, 0, 1, MAY_BE_RESOURCE|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, fontname, IS_STRING, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_load_image, 0, 1, MAY_BE_RESOURCE|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_STRING, 0) ZEND_ARG_TYPE_INFO(1, err, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_load_image_with_error_return, 0, 2, MAY_BE_RESOURCE|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_STRING, 0) ZEND_ARG_TYPE_INFO(1, err, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_polygon_add_point, 0, 3, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, polygon, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_polygon_contains_point, 0, 3, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, polygon, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_polygon_free, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, polygon, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_polygon_get_bounds, 0, 5, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, polygon, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(1, x1, IS_LONG, 0) ZEND_ARG_TYPE_INFO(1, y1, IS_LONG, 0) ZEND_ARG_TYPE_INFO(1, x2, IS_LONG, 0) ZEND_ARG_TYPE_INFO(1, y2, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_polygon_new, 0, 0, MAY_BE_RESOURCE|MAY_BE_NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_save_image, 0, 2, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0) ZEND_ARG_TYPE_INFO(1, err, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, quality, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_save_image_with_error_return, 0, 3, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0) ZEND_ARG_TYPE_INFO(1, err, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, quality, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_text_draw, 0, 10, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, font, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, direction, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_get_cache_size, 0, 0, MAY_BE_LONG) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_set_cache_size, 0, 1, MAY_BE_TRUE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, bytes, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_create_filter, 0, 0, MAY_BE_RESOURCE|MAY_BE_NULL) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_free_filter, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, filter, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_image_filter, 0, 2, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, filter, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_filter_set, 0, 7, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, filter, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, xoff, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, yoff, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_filter_set_alpha, 0, 7, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, filter, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, xoff, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, yoff, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_filter_set_red, 0, 7, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, filter, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, xoff, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, yoff, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_filter_set_green, 0, 7, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, filter, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, xoff, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, yoff, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_filter_set_blue, 0, 7, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, filter, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, xoff, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, yoff, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_filter_constants, 0, 5, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, filter, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_filter_divisors, 0, 5, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, filter, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_apply_filter, 0, 2, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, filter, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, params, IS_ARRAY, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_modify_color_modifier_gamma, 0, 2, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, cm, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, gamma_value, IS_DOUBLE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_modify_color_modifier_brightness, 0, 2, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, cm, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, brightness_value, IS_DOUBLE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_modify_color_modifier_contrast, 0, 2, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, cm, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, contrast_value, IS_DOUBLE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_reset_color_modifier, 0, 1, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, cm, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_apply_color_modifier, 0, 2, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, cm, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, width, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, height, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_set_color_modifier, 0, 3, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, cm, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, channels, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_get_color_modifier, 0, 6, MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, cm, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_ARG_TYPE_INFO(1, red, IS_LONG, 0) ZEND_ARG_TYPE_INFO(1, green, IS_LONG, 0) ZEND_ARG_TYPE_INFO(1, blue, IS_LONG, 0) ZEND_ARG_TYPE_INFO(1, alpha, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_psloadfont, 0, 1, MAY_BE_RESOURCE|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, pathname, IS_STRING, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_psfreefont, 0, 1, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, font_index, IS_RESOURCE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_psencodefont, 0, 2, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, font_index, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_psextendfont, 0, 2, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, font_index, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, extend, IS_DOUBLE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_psslantfont, 0, 2, MAY_BE_BOOL|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, font_index, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, slant, IS_DOUBLE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_pstext, 0, 10, MAY_BE_ARRAY|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, img, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, text, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, font, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, g, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, b, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, a, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, space, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, tightness, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, angle, IS_DOUBLE, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, antialias, IS_LONG, 0, "4") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imlib_psbbox, 0, 3, MAY_BE_ARRAY|MAY_BE_FALSE|MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, text, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, font, IS_RESOURCE, 0) ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, space, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, tightness, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, angle, IS_DOUBLE, 0, "0") ZEND_END_ARG_INFO() static const char le_imlib_cr_name[] = "Imlib Color Range"; static int le_imlib_cr; static const char le_imlib_font_name[] = "Imlib Font"; static int le_imlib_font; static const char le_imlib_img_name[] = "Imlib Image"; static int le_imlib_img; static const char le_imlib_poly_name[] = "Imlib Polygon"; static int le_imlib_poly; static const char le_imlib_filter_name[] = "Imlib Filter"; static int le_imlib_filter; static const char le_imlib_cm_name[] = "Imlib Color Modifier"; static int le_imlib_cm; #if HAVE_LIBT1 static const char le_ps_font_name[] = "Type 1 font"; static int le_ps_font; static int le_ps_enc; #endif zend_function_entry imlib_functions[] = { PHP_FE(imlib_add_color_to_color_range,arginfo_imlib_add_color_to_color_range) PHP_FE(imlib_blend_image_onto_image,arginfo_imlib_blend_image_onto_image) PHP_FE(imlib_clone_image,arginfo_imlib_clone_image) PHP_FE(imlib_create_color_range,arginfo_imlib_create_color_range) PHP_FE(imlib_create_color_modifier,arginfo_imlib_create_color_modifier) PHP_FE(imlib_create_cropped_image,arginfo_imlib_create_cropped_image) PHP_FE(imlib_create_cropped_scaled_image,arginfo_imlib_create_cropped_scaled_image) PHP_FE(imlib_create_image,arginfo_imlib_create_image) PHP_FE(imlib_create_rotated_image,arginfo_imlib_create_rotated_image) PHP_FE(imlib_create_scaled_image,arginfo_imlib_create_scaled_image) PHP_FE(imlib_dump_image,arginfo_imlib_dump_image) PHP_FE(imlib_free_color_range,arginfo_imlib_free_color_range) PHP_FE(imlib_free_color_modifier,arginfo_imlib_free_color_modifier) PHP_FE(imlib_free_font,arginfo_imlib_free_font) PHP_FE(imlib_free_image,arginfo_imlib_free_image) PHP_FE(imlib_get_text_size,arginfo_imlib_get_text_size) PHP_FE(imlib_get_text_advance,arginfo_imlib_get_text_advance) PHP_FE(imlib_image_blur,arginfo_imlib_image_blur) PHP_FE(imlib_image_draw_ellipse,arginfo_imlib_image_draw_ellipse) PHP_FE(imlib_image_draw_line,arginfo_imlib_image_draw_line) PHP_FE(imlib_image_draw_polygon,arginfo_imlib_image_draw_polygon) PHP_FE(imlib_image_draw_rectangle,arginfo_imlib_image_draw_rectangle) PHP_FE(imlib_image_fill_color_range_rectangle,arginfo_imlib_image_fill_color_range_rectangle) PHP_FE(imlib_image_fill_ellipse,arginfo_imlib_image_fill_ellipse) PHP_FE(imlib_image_fill_polygon,arginfo_imlib_image_fill_polygon) PHP_FE(imlib_image_fill_rectangle,arginfo_imlib_image_fill_rectangle) PHP_FE(imlib_image_flip_horizontal,arginfo_imlib_image_flip_horizontal) PHP_FE(imlib_image_flip_vertical,arginfo_imlib_image_flip_vertical) PHP_FE(imlib_image_flip_diagonal,arginfo_imlib_image_flip_diagonal) PHP_FE(imlib_image_orientate,arginfo_imlib_image_orientate) PHP_FE(imlib_image_format,arginfo_imlib_image_format) PHP_FE(imlib_image_get_filename,arginfo_imlib_image_get_filename) PHP_FE(imlib_image_get_height,arginfo_imlib_image_get_height) PHP_FE(imlib_image_get_width,arginfo_imlib_image_get_width) PHP_FE(imlib_image_has_alpha,arginfo_imlib_image_has_alpha) PHP_FE(imlib_image_modify_alpha,arginfo_imlib_image_modify_alpha) PHP_FE(imlib_image_sharpen,arginfo_imlib_image_sharpen) PHP_FE(imlib_image_set_format,arginfo_imlib_image_set_format) PHP_FE(imlib_image_tile_horizontal,arginfo_imlib_image_tile_horizontal) PHP_FE(imlib_image_tile_vertical,arginfo_imlib_image_tile_vertical) PHP_FE(imlib_image_tile,arginfo_imlib_image_tile) PHP_FE(imlib_list_fonts,arginfo_imlib_list_fonts) PHP_FE(imlib_load_font,arginfo_imlib_load_font) PHP_FE(imlib_load_image,arginfo_imlib_load_image) PHP_FALIAS(imlib_load_image_with_error_return,imlib_load_image,arginfo_imlib_load_image_with_error_return) PHP_FE(imlib_polygon_add_point,arginfo_imlib_polygon_add_point) PHP_FE(imlib_polygon_contains_point,arginfo_imlib_polygon_contains_point) PHP_FE(imlib_polygon_free,arginfo_imlib_polygon_free) PHP_FE(imlib_polygon_get_bounds,arginfo_imlib_polygon_get_bounds) PHP_FE(imlib_polygon_new,arginfo_imlib_polygon_new) PHP_FE(imlib_save_image,arginfo_imlib_save_image) PHP_FALIAS(imlib_save_image_with_error_return,imlib_save_image,arginfo_imlib_save_image_with_error_return) PHP_FE(imlib_text_draw,arginfo_imlib_text_draw) PHP_FE(imlib_get_cache_size,arginfo_imlib_get_cache_size) PHP_FE(imlib_set_cache_size,arginfo_imlib_set_cache_size) PHP_FE(imlib_create_filter,arginfo_imlib_create_filter) PHP_FE(imlib_free_filter,arginfo_imlib_free_filter) PHP_FE(imlib_image_filter,arginfo_imlib_image_filter) PHP_FE(imlib_filter_set,arginfo_imlib_filter_set) PHP_FE(imlib_filter_set_alpha,arginfo_imlib_filter_set_alpha) PHP_FE(imlib_filter_set_red,arginfo_imlib_filter_set_red) PHP_FE(imlib_filter_set_green,arginfo_imlib_filter_set_green) PHP_FE(imlib_filter_set_blue,arginfo_imlib_filter_set_blue) PHP_FE(imlib_filter_constants,arginfo_imlib_filter_constants) PHP_FE(imlib_filter_divisors,arginfo_imlib_filter_divisors) PHP_FE(imlib_apply_filter,arginfo_imlib_apply_filter) PHP_FE(imlib_modify_color_modifier_gamma,arginfo_imlib_modify_color_modifier_gamma) PHP_FE(imlib_modify_color_modifier_brightness,arginfo_imlib_modify_color_modifier_brightness) PHP_FE(imlib_modify_color_modifier_contrast,arginfo_imlib_modify_color_modifier_contrast) PHP_FE(imlib_reset_color_modifier,arginfo_imlib_reset_color_modifier) PHP_FE(imlib_apply_color_modifier,arginfo_imlib_apply_color_modifier) PHP_FE(imlib_set_color_modifier,arginfo_imlib_set_color_modifier) PHP_FE(imlib_get_color_modifier,arginfo_imlib_get_color_modifier) PHP_FE(imlib_psloadfont,arginfo_imlib_psloadfont) PHP_FE(imlib_psfreefont,arginfo_imlib_psfreefont) PHP_FE(imlib_psencodefont,arginfo_imlib_psencodefont) PHP_FE(imlib_psextendfont,arginfo_imlib_psextendfont) PHP_FE(imlib_psslantfont,arginfo_imlib_psslantfont) PHP_FE(imlib_pstext,arginfo_imlib_pstext) PHP_FE(imlib_psbbox,arginfo_imlib_psbbox) {NULL, NULL, NULL} }; ZEND_DECLARE_MODULE_GLOBALS(imlib) PHP_INI_BEGIN() STD_PHP_INI_ENTRY("imlib.font_path","/usr/local/share/fonts",PHP_INI_SYSTEM|PHP_INI_PERDIR,OnUpdateString,font_path,zend_imlib_globals,imlib_globals) STD_PHP_INI_ENTRY("imlib.min_cache_size","0",PHP_INI_SYSTEM,OnUpdateLong,min_cache_size,zend_imlib_globals,imlib_globals) STD_PHP_INI_ENTRY("imlib.max_cache_size","4194304",PHP_INI_SYSTEM,OnUpdateLong,max_cache_size,zend_imlib_globals,imlib_globals) STD_PHP_INI_ENTRY("imlib.cache_size","0",PHP_INI_SYSTEM|PHP_INI_PERDIR,OnUpdateLong,cache_size,zend_imlib_globals,imlib_globals) PHP_INI_ENTRY("imlib.font_cache_size","524288",PHP_INI_SYSTEM,OnUpdateFontCacheSize) STD_PHP_INI_ENTRY("imlib.filter_path",PHP_IMLIB_FILTER_PATH,PHP_INI_SYSTEM,OnUpdateString,filter_path,zend_imlib_globals,imlib_globals) PHP_INI_END() /* {{{ php_imlib_init_globals */ static void php_imlib_init_globals(zend_imlib_globals *imlib_globals) { imlib_globals->font_path = NULL; imlib_globals->min_cache_size = 0; imlib_globals->max_cache_size = 4194304; imlib_globals->cache_size = 0; imlib_globals->filter_path = NULL; imlib_globals->saved_path = NULL; imlib_globals->filters = NULL; } zend_module_entry imlib_module_entry = { STANDARD_MODULE_HEADER, "imlib", imlib_functions, PHP_MINIT(imlib), PHP_MSHUTDOWN(imlib), PHP_RINIT(imlib), PHP_RSHUTDOWN(imlib), PHP_MINFO(imlib), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES }; PHP_INI_MH(OnUpdateFontCacheSize) { int size; if (sscanf(new_value->val,"%d",&size)==1) { imlib_set_font_cache_size(size); return SUCCESS; } else { return FAILURE; } } ZEND_RSRC_DTOR_FUNC(_php_imlib_free_cm) { imlib_context_set_color_modifier(((PHP_Imlib_Color_Modifier)res->ptr)->cm); efree(res->ptr); imlib_free_color_modifier(); } ZEND_RSRC_DTOR_FUNC(_php_imlib_free_filter) { imlib_context_set_filter(res->ptr); imlib_free_filter(); } ZEND_RSRC_DTOR_FUNC(_php_imlib_free_cr) { imlib_context_set_color_range(res->ptr); imlib_free_color_range(); } ZEND_RSRC_DTOR_FUNC(_php_imlib_free_font) { imlib_context_set_font(((PHP_Imlib_Font)res->ptr)->font); efree(res->ptr); imlib_free_font(); } ZEND_RSRC_DTOR_FUNC(_php_imlib_free_img) { imlib_context_set_image(res->ptr); imlib_free_image(); } ZEND_RSRC_DTOR_FUNC(_php_imlib_free_poly) { imlib_polygon_free(res->ptr); } void _php_imlib_set_cache_size(int size) { if (size>IMLIBG(max_cache_size)) { size=IMLIBG(max_cache_size); } if (sizefilename=strdup(file); ptr->handle=lt_dlopenext(file); if (!ptr->handle) goto error; #ifdef IMLIB_DEBUG ID_PRINTF("Library loaded, handle=%p. Looking for entry points...",ptr->handle); #endif ptr->init=lt_dlsym(ptr->handle,"php_filter_init"); ptr->deinit=lt_dlsym(ptr->handle,"php_filter_deinit"); ptr->exec=lt_dlsym(ptr->handle,"php_filter_exec"); ptr->getfiltercount=lt_dlsym(ptr->handle,"php_filter_getfiltercount"); ptr->getfilternames=lt_dlsym(ptr->handle,"php_filter_getfilternames"); ptr->getextinfo=lt_dlsym(ptr->handle,"php_filter_getextinfo"); ptr->getparams=lt_dlsym(ptr->handle,"php_filter_getparams"); #ifdef IMLIB_DEBUG ID_PRINTF("Function pointers: init=%p, deinit=%p, exec=%p, count=%p, names=%p",ptr->init,ptr->deinit,ptr->exec,ptr->getfiltercount,ptr->getfilternames); #endif if (!ptr->getfiltercount || !ptr->getfilternames || !ptr->exec) goto error; #ifdef IMLIB_DEBUG ID_PRINTF("Getting filter info..."); #endif if (ptr->init) { initrv=ptr->init(); if (initrv==FAILURE) goto error; } ptr->filters=ptr->getfiltercount(); ptr->names=malloc(ptr->filters*sizeof(char*)); if (!ptr->names) goto error; ptr->getfilternames(ptr->names); ptr->next=NULL; return ptr; error: #ifdef IMLIB_DEBUG ID_PRINTF("Error loading library!"); #endif if (ptr) { if (ptr->handle) { if (ptr->deinit) { if (initrv==SUCCESS) ptr->deinit(); } lt_dlclose(ptr->handle); } if (ptr->names) free(ptr->names); if (ptr->filename) free(ptr->filename); free(ptr); } return NULL; } void _php_imlib_unload_filter(struct php_imlib_filter* ptr) { if (ptr==NULL) return; if (ptr->deinit) ptr->deinit(); if (ptr->names) free(ptr->names); if (ptr->filename) free(ptr->filename); lt_dlclose(ptr->handle); free(ptr); } void _php_imlib_unload_filters(void) { struct php_imlib_filter* f_ptr; f_ptr=IMLIBG(filters); while (f_ptr!=NULL) { struct php_imlib_filter* f_ptr_next; f_ptr_next=f_ptr->next; _php_imlib_unload_filter(f_ptr); f_ptr=f_ptr_next; } IMLIBG(filters)=NULL; lt_dlexit(); } void _php_imlib_load_filters(void) { struct php_imlib_filter* f_ptr; char* path; DIR* dirp=NULL; struct dirent *dp; char** names=NULL; int names_size,names_index,i; int ltinitrv=0; f_ptr=IMLIBG(filters); if (f_ptr!=NULL) return; #ifdef IMLIB_DEBUG ID_PRINTF("Initializing libltdl..."); #endif if ((ltinitrv=lt_dlinit())>0) goto error; #ifdef IMLIB_DEBUG ID_PRINTF("Loading filters..."); #endif path=IMLIBG(filter_path); lt_dladdsearchdir(path); #ifdef IMLIB_DEBUG ID_PRINTF("Opening directory %s...",path); #endif if ((dirp=opendir(path))==NULL) goto error; names_size=20; names_index=0; if ((names=malloc(names_size*sizeof(char*)))==NULL) goto error; #ifdef IMLIB_DEBUG ID_PRINTF("Scanning directory..."); #endif errno=0; while ((dp=readdir(dirp))!=NULL) { char* name; if ((name=strdup(dp->d_name))==NULL) goto error; if ((strcmp(name, ".")) && (strcmp(name, ".."))) { char* ext; ext=strchr(name,'.'); if (ext) { *ext='\0'; for (i=0;i0) { IMLIBG(filters)=f_ptr=malloc(sizeof(struct php_imlib_filter)); for (i=0;inext=_php_imlib_load_filter(names[i]))!=NULL) f_ptr=f_ptr->next; } IMLIBG(filters)=IMLIBG(filters)->next; } goto cleanup; error: #ifdef IMLIB_DEBUG ID_PRINTF("Error loading filters!"); #endif _php_imlib_unload_filters(); cleanup: if (names!=NULL) { for (i=0;ifilters;i++) { if (strcmp(f_ptr->names[i],filter_name)==0) { return f_ptr; } } f_ptr=f_ptr->next; } return NULL; } Imlib_Image _php_imlib_get_image(zval* im_resource) { Imlib_Image im; im = (Imlib_Image) zend_fetch_resource(Z_RES_P(im_resource), le_imlib_img_name, le_imlib_img); return im; } Imlib_Filter _php_imlib_get_filter(zval* fil_resource) { Imlib_Filter fil; fil = (Imlib_Filter) zend_fetch_resource(Z_RES_P(fil_resource), le_imlib_filter_name, le_imlib_filter); return fil; } void _php_imlib_color_modifier_synch(PHP_Imlib_Color_Modifier cm) { if ((cm->modified)&&(!cm->valid)) { fprintf(stderr,"Panic!! Color Modifier in invalid state!"); return; } imlib_context_set_color_modifier(cm->cm); if (cm->modified) { imlib_set_color_modifier_tables(cm->channels[0],cm->channels[1],cm->channels[2],cm->channels[3]); cm->modified=0; } if (!cm->valid) { imlib_get_color_modifier_tables(cm->channels[0],cm->channels[1],cm->channels[2],cm->channels[3]); cm->valid=1; } imlib_context_set_color_modifier(NULL); } Imlib_Color_Modifier _php_imlib_get_cm(zval* cm_resource) { PHP_Imlib_Color_Modifier cm; cm = (Imlib_Color_Modifier) zend_fetch_resource(Z_RES_P(cm_resource), le_imlib_cm_name, le_imlib_cm); if (cm->modified) _php_imlib_color_modifier_synch(cm); cm->valid=0; return cm->cm; } Imlib_Font _php_imlib_get_font(zval* font_resource) { PHP_Imlib_Font php_font; php_font = (PHP_Imlib_Font) zend_fetch_resource(Z_RES_P(font_resource), le_imlib_font_name, le_imlib_font); return php_font->font; } Imlib_Color_Range _php_imlib_get_cr(zval* cr_resource) { Imlib_Color_Range cr; cr = (Imlib_Color_Range) zend_fetch_resource(Z_RES_P(cr_resource), le_imlib_cr_name, le_imlib_cr); return cr; } ImlibPolygon _php_imlib_get_poly(zval* poly_resource) { ImlibPolygon poly; poly = (ImlibPolygon) zend_fetch_resource(Z_RES_P(poly_resource), le_imlib_poly_name, le_imlib_poly); return poly; } #if HAVE_LIBT1 /* {{{ _php_imlib_free_ps_font */ ZEND_RSRC_DTOR_FUNC(_php_imlib_free_ps_font) { int *font = (int *)res->ptr; T1_DeleteFont(*font); efree(font); } /* }}} */ /* {{{ _php_imlib_free_ps_enc */ ZEND_RSRC_DTOR_FUNC(_php_imlib_free_ps_enc) { char **enc = (char **)res->ptr; T1_DeleteEncoding(enc); } /* }}} */ #endif #ifdef COMPILE_DL_IMLIB ZEND_GET_MODULE(imlib) #endif /* {{{ PHP_MINIT_FUNCTION */ ZEND_MODULE_STARTUP_D(imlib) { ZEND_INIT_MODULE_GLOBALS(imlib, php_imlib_init_globals, NULL); le_imlib_cr = zend_register_list_destructors_ex(_php_imlib_free_cr,NULL,"imlib color range",module_number); le_imlib_font = zend_register_list_destructors_ex(_php_imlib_free_font,NULL,"imlib font",module_number); le_imlib_img = zend_register_list_destructors_ex(_php_imlib_free_img,NULL,"imlib image",module_number); le_imlib_poly = zend_register_list_destructors_ex(_php_imlib_free_poly,NULL,"imlib polygon",module_number); le_imlib_filter = zend_register_list_destructors_ex(_php_imlib_free_filter,NULL,"imlib filter",module_number); le_imlib_cm = zend_register_list_destructors_ex(_php_imlib_free_cm,NULL,"imlib color modifier",module_number); #if HAVE_LIBT1 T1_SetBitmapPad(8); T1_InitLib(NO_LOGFILE|IGNORE_CONFIGFILE|IGNORE_FONTDATABASE); T1_SetLogLevel(T1LOG_DEBUG); le_ps_font = zend_register_list_destructors_ex(_php_imlib_free_ps_font, NULL, "imlib PS font", module_number); le_ps_enc = zend_register_list_destructors_ex(_php_imlib_free_ps_enc, NULL, "imlib PS encoding", module_number); #endif REGISTER_LONG_CONSTANT("IMLIB_TEXT_TO_RIGHT", IMLIB_TEXT_TO_RIGHT, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_TEXT_TO_LEFT", IMLIB_TEXT_TO_LEFT, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_TEXT_TO_DOWN", IMLIB_TEXT_TO_DOWN, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_TEXT_TO_UP", IMLIB_TEXT_TO_UP, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_TEXT_TO_ANGLE", IMLIB_TEXT_TO_ANGLE, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_CHANNEL_RED", 1, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_CHANNEL_GREEN", 2, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_CHANNEL_BLUE", 4, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_CHANNEL_ALPHA", 8, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_NONE", IMLIB_LOAD_ERROR_NONE, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST", IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY", IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ", IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT", IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_PATH_TOO_LONG", IMLIB_LOAD_ERROR_PATH_TOO_LONG, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT", IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY", IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE", IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS", IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_OUT_OF_MEMORY", IMLIB_LOAD_ERROR_OUT_OF_MEMORY, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS", IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE", IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE", IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IMLIB_LOAD_ERROR_UNKNOWN", IMLIB_LOAD_ERROR_UNKNOWN, CONST_CS|CONST_PERSISTENT); REGISTER_INI_ENTRIES(); return SUCCESS; } PHP_MSHUTDOWN_FUNCTION(imlib) { _php_imlib_unload_filters(); UNREGISTER_INI_ENTRIES(); return SUCCESS; } PHP_RINIT_FUNCTION(imlib) { char **font_list; char *pathbuf, *ptr, *end; int i, font_count; /* Set default cache size */ _php_imlib_set_cache_size(IMLIBG(cache_size)); font_list = imlib_list_font_path(&font_count); if (!font_count) { IMLIBG(saved_path) = NULL; } else { /* Save the current path where we can retrieve it later. */ IMLIBG(saved_path) = (char **) emalloc(sizeof(char *) * (font_count + 1)); for (i = 0; i < font_count; i++) { IMLIBG(saved_path)[i] = estrdup(font_list[i]); } IMLIBG(saved_path)[i] = NULL; /* Now clear the imlib path... */ for (i = 0; i < font_count; i++) { imlib_remove_path_from_font_path(IMLIBG(saved_path)[i]); } } if (!IMLIBG(font_path)) { return SUCCESS; } /* And repopulate it with the ini-specified default. */ ptr = pathbuf = estrdup(IMLIBG(font_path)); while (ptr && *ptr) { end = strchr(ptr, ':'); if (end != NULL) { *end = '\0'; end++; } imlib_add_path_to_font_path(ptr); ptr = end; } efree(pathbuf); return SUCCESS; } PHP_RSHUTDOWN_FUNCTION(imlib) { char **font_list; int i, font_count; /* Restore cache size */ _php_imlib_set_cache_size(0); /* Retrieve the current path and clear it out. */ font_list = imlib_list_font_path(&font_count); for (i = 0; i < font_count; i++) { imlib_remove_path_from_font_path(font_list[i]); } /* Restore the saved font path. */ if (!IMLIBG(saved_path)) { return SUCCESS; } for (i = 0; IMLIBG(saved_path)[i] != NULL; i++) { imlib_add_path_to_font_path(IMLIBG(saved_path)[i]); efree(IMLIBG(saved_path)[i]); } efree(IMLIBG(saved_path)); return SUCCESS; } PHP_MINFO_FUNCTION(imlib) { struct php_imlib_filter* f_ptr; int i; _php_imlib_load_filters(); f_ptr=IMLIBG(filters); DISPLAY_INI_ENTRIES(); #ifdef HAVE_LIBT1 php_info_print_table_start(); php_info_print_table_row(2, "T1Lib Support", "enabled"); php_info_print_table_end(); #endif while (f_ptr!=NULL) { char* extinfo[3] = {NULL, NULL, NULL}; php_info_print_table_start(); if (f_ptr->getextinfo) f_ptr->getextinfo(extinfo); if (extinfo[0]) { char* infostr; f_ptr->getextinfo(extinfo); infostr=emalloc((strlen(extinfo[0])+strlen(f_ptr->filename)+4)*sizeof(char)); strcpy(infostr,extinfo[0]); strcat(infostr," ("); strcat(infostr,f_ptr->filename); strcat(infostr,")"); php_info_print_table_row(2, "Filter name", infostr); efree(infostr); } else { php_info_print_table_row(2, "Filter name", f_ptr->filename); } if (extinfo[1]) php_info_print_table_row(2,"Description",extinfo[1]); if (extinfo[2]) php_info_print_table_row(2,"Author",extinfo[2]); { char* filters; filters=estrdup(""); for (i=0;ifilters;i++) { int newlen; char* params=NULL; if (f_ptr->getparams) params=f_ptr->getparams(f_ptr->names[i]); newlen=strlen(filters)+strlen(f_ptr->names[i])+2; if (params) newlen+=strlen(params)+3; filters=erealloc(filters,newlen*sizeof(char)); if (filters) { strcat(filters,f_ptr->names[i]); if (params) { strcat(filters," ("); strcat(filters,params); strcat(filters,")"); } strcat(filters,"\n"); } } php_info_print_table_row(2,"Filters",filters); efree(filters); } f_ptr=f_ptr->next; php_info_print_table_end(); } } static int _php_handle_cliprect_array(zval **dbox, char *func_name, int *x, int *y, int *w, int *h) { zval *element, **box_coords; int i,arrcount; HashTable *box; box = HASH_OF(*dbox); if (!box) { php_error(E_WARNING, "Wrong datatype in call to %s, need array",func_name); return 0; } arrcount = zend_hash_num_elements(box); if (arrcount != 4) { php_error(E_WARNING, "Wrong number of array elements in call to %s, need four (x,y,w,h)", func_name); return 0; } box_coords = (zval **)emalloc(arrcount * sizeof(zval *)); for (i = 0; i < arrcount; i++) { if (element = zend_hash_index_find(box, i)) { convert_to_long_ex(element); box_coords[i] = element; } } *x = Z_LVAL_P(box_coords[0]); *y = Z_LVAL_P(box_coords[1]); *w = Z_LVAL_P(box_coords[2]); *h = Z_LVAL_P(box_coords[3]); efree(box_coords); return 1; } static int _php_handle_imlib_error(INTERNAL_FUNCTION_PARAMETERS, Imlib_Load_Error err, const char *img) { int errnum; switch (err) { case IMLIB_LOAD_ERROR_NONE: errnum = 0; break; case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST: php_error(E_WARNING, "%s - File does not exist", img); errnum = 1; break; case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY: php_error(E_WARNING, "%s - Directory specified for image filename", img); errnum = 2; break; case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ: php_error(E_WARNING, "%s - No read access to directory", img); errnum = 3; break; case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT: php_error(E_WARNING, "%s - No Imlib2 loader for that file format", img); errnum = 4; break; case IMLIB_LOAD_ERROR_PATH_TOO_LONG: php_error(E_WARNING, "%s - Path specified is too long", img); errnum = 5; break; case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT: php_error(E_WARNING, "%s - Path component does not exist", img); errnum = 6; break; case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY: php_error(E_WARNING, "%s - Path component is not a directory", img); errnum = 7; break; case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE: php_error(E_WARNING, "%s - Path points outside address space", img); errnum = 8; break; case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS: php_error(E_WARNING, "%s - Too many levels of symbolic links", img); errnum = 9; break; case IMLIB_LOAD_ERROR_OUT_OF_MEMORY: php_error(E_WARNING, "While loading %s - Out of memory", img); errnum = 10; break; case IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS: php_error(E_WARNING, "While loading %s - Out of file descriptors", img); errnum = 11; break; case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE: php_error(E_WARNING, "%s - Cannot write to directory", img); errnum = 12; break; case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE: php_error(E_WARNING, "%s - Cannot write - out of disk space", img); errnum = 13; break; case IMLIB_LOAD_ERROR_UNKNOWN: default: php_error(E_WARNING, "While loading %s - Unknown error.", img); errnum = 14; } return errnum; } static void _php_imlib_draw_something(INTERNAL_FUNCTION_PARAMETERS, void (*func)(), char *func_name) { int argc; int cx, cy, cw, ch; zval *img, *dbox; zend_long x,y,w,h,r,g,b,a; Imlib_Image im; argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc, "rllllllll|a", &img, &x, &y, &w, &h, &r, &g, &b, &a, &dbox) == FAILURE) { return; } if ((im = (Imlib_Image)zend_fetch_resource(Z_RES_P(img), le_imlib_img_name, le_imlib_img)) == NULL) RETURN_FALSE; imlib_context_set_image(im); imlib_context_set_color(r,g,b,a); /* FIXME: This should take an optional antialias option, with on as default */ imlib_context_set_anti_alias(0); if (argc > 9) { if (!_php_handle_cliprect_array(&dbox, func_name, &cx,&cy,&cw,&ch)) RETURN_FALSE; imlib_context_set_cliprect(cx,cy,cw,ch); } (*func)(x,y,w,h); imlib_context_set_cliprect(0,0,0,0); RETURN_TRUE; } static void _php_imlib_single_arg(INTERNAL_FUNCTION_PARAMETERS, void (*func)()) { zval *img; Imlib_Image im; if (zend_parse_parameters(1, "r", &img) == FAILURE) return; if ((im = (Imlib_Image)zend_fetch_resource(Z_RES_P(img), le_imlib_img_name, le_imlib_img)) == NULL) RETURN_FALSE; imlib_context_set_image(im); (*func)(); } /* We wrap imlib_image_draw_line, because it doesn't return a void like all the other drawing functions do. So, since we don't care about Imlib_Updates, we're going to return our own void. Nyeh. */ static void _php_wrap_draw_line(int x1, int y1, int x2, int y2) { imlib_image_draw_line(x1,y1,x2,y2,0); } /* {{{ proto void imlib_add_color_to_color_range(int cr, int x, int r, int g, int b, int a) Add a color to a color range at a specified distance from the previous color in the range. A distance of 0 centers it */ PHP_FUNCTION(imlib_add_color_to_color_range) { zval *crange; zend_long x,r,g,b,a; Imlib_Color_Range range; if (zend_parse_parameters(6, "rlllll", &crange, &x, &r, &g, &b, &a) == FAILURE) return; if ((range = (Imlib_Color_Range)zend_fetch_resource(Z_RES_P(crange), le_imlib_cr_name, le_imlib_cr)) == NULL) RETURN_FALSE; imlib_context_set_color_range(range); imlib_context_set_color(r,g,b,a); imlib_add_color_to_color_range(x); } /* }}} */ /* {{{ proto void imlib_blend_image_onto_image(int dstimg, int srcimg, int malpha, int srcx, int srcy, int srcw, int srch, int dstx, int dsty, int dstw, int dsth, char dither, char blend, char alias) Blend a rectangular area from an image onto an area of another image, scaling as necessary */ PHP_FUNCTION(imlib_blend_image_onto_image) { zval *dstimg, *srcimg; Imlib_Image dst,src; zend_long sx,sy,sw,sh,dx,dy,dw,dh; zend_long calias, calpha, cblend, cdither; if (zend_parse_parameters(14, "rrllllllllllll", &dstimg, &srcimg, &calpha, &sx, &sy, &sw, &sh, &dx, &dy, &dw, &dh, &cdither, &cblend, &calias) == FAILURE) return; if ((src = (Imlib_Image)zend_fetch_resource(Z_RES_P(srcimg), le_imlib_img_name, le_imlib_img)) == NULL) RETURN_FALSE; if ((dst = (Imlib_Image)zend_fetch_resource(Z_RES_P(dstimg), le_imlib_img_name, le_imlib_img)) == NULL) RETURN_FALSE; imlib_context_set_image(dst); imlib_context_set_anti_alias(calias); imlib_context_set_dither(cdither); imlib_context_set_blend(cblend); imlib_context_set_angle(0); imlib_blend_image_onto_image(src,calpha,sx,sy,sw,sh,dx,dy,dw,dh); } /* }}} */ /* {{{ proto int imlib_clone_image(int img) Duplicate an image */ PHP_FUNCTION(imlib_clone_image) { zval *img; Imlib_Image src,dst; if (zend_parse_parameters(1, "r", &img) == FAILURE) return; if ((src = (Imlib_Image)zend_fetch_resource(Z_RES_P(img), le_imlib_img_name, le_imlib_img)) == NULL) RETURN_FALSE; imlib_context_set_image(src); dst = imlib_clone_image(); if (dst) RETURN_RES(zend_register_resource(dst, le_imlib_img)); } /* }}} */ /* {{{ proto int imlib_create_color_range() Create a new color range */ PHP_FUNCTION(imlib_create_color_range) { Imlib_Color_Range cr; if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } cr = imlib_create_color_range(); if (cr) RETURN_RES(zend_register_resource(cr, le_imlib_cr)); } /* }}} */ /* {{{ proto int imlib_create_color_modifier(void) Create a new color modifier */ PHP_FUNCTION(imlib_create_color_modifier) { PHP_Imlib_Color_Modifier cm; if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } cm=(PHP_Imlib_Color_Modifier)emalloc(sizeof(PHP_Imlib_Color_Modifier_struct)); if (!cm) RETURN_FALSE; cm->cm = imlib_create_color_modifier(); cm->modified=0; cm->valid=0; if (!cm->cm) { efree(cm); RETURN_FALSE; } RETURN_RES(zend_register_resource(cm, le_imlib_cm)); } /* }}} */ /* {{{ proto int imlib_create_cropped_image(int img, int srcx, int srcy, int srcw, int srch) Create an image from a cropped region of another image */ PHP_FUNCTION(imlib_create_cropped_image) { zval *img; zend_long sx,sy,sw,sh; Imlib_Image src,dst; if (zend_parse_parameters(5, "rllll", &img, &sx, &sy, &sw, &sh) == FAILURE) return; if ((src = (Imlib_Image)zend_fetch_resource(Z_RES_P(img), le_imlib_img_name, le_imlib_img)) == NULL) RETURN_FALSE; imlib_context_set_image(src); dst = imlib_create_cropped_image(sx,sy,sw,sh); if (dst) RETURN_RES(zend_register_resource(dst, le_imlib_img)); } /* }}} */ /* {{{ proto int imlib_create_cropped_scaled_image(int img, int srcx, int srcy, int srcw, int srch, int dstw, int dsth) Create a scaled image from a cropped region of another image */ PHP_FUNCTION(imlib_create_cropped_scaled_image) { zval *img; zend_long sx,sy,sw,sh,dw,dh; Imlib_Image src,dst; if (zend_parse_parameters(7, "rllllll", &img, &sx, &sy, &sw, &sh, &dw, &dh) == FAILURE) return; if ((src = (Imlib_Image)zend_fetch_resource(Z_RES_P(img), le_imlib_img_name, le_imlib_img)) == NULL) RETURN_FALSE; imlib_context_set_image(src); dst = imlib_create_cropped_scaled_image(sx,sy, sw,sh, dw,dh); if (dst) RETURN_RES(zend_register_resource(dst, le_imlib_img)); } /* }}} */ /* {{{ proto int imlib_create_image(int w, int h) Create a new image with the specified dimensions */ PHP_FUNCTION(imlib_create_image) { Imlib_Image im; zend_long x,y; if (zend_parse_parameters(2, "ll", &x, &y) == FAILURE) return; im = imlib_create_image(x,y); if (im) { imlib_context_set_image(im); memset(imlib_image_get_data(), '\0', x * y * sizeof(DATA32)); RETURN_RES(zend_register_resource(im, le_imlib_img)); } } /* }}} */ /* {{{ proto int imlib_create_rotated_image(int srcimg, int degrees[, int radians]) Create a rotated copy of an image. If radians is specified, degrees will be ignored. */ PHP_FUNCTION(imlib_create_rotated_image) { /* Contributed by Gareth Ardron */ zval *srcimg; double angle, radians; int argc; Imlib_Image src, dst; argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc, "rd|d", &srcimg, &angle, &radians) == FAILURE) return; if ((src = (Imlib_Image)zend_fetch_resource(Z_RES_P(srcimg), le_imlib_img_name, le_imlib_img)) == NULL) RETURN_FALSE; if (argc == 2) radians = angle * M_PI/180; imlib_context_set_image(src); dst = imlib_create_rotated_image(radians); if (dst) RETURN_RES(zend_register_resource(dst, le_imlib_img)); } /* }}} */ /* {{{ proto int imlib_create_scaled_image(int img, int dstw, int dsth) Create a scaled copy of an image. If dstw or dsth is left blank, the aspect ratio of the source image will be preserved. */ PHP_FUNCTION(imlib_create_scaled_image) { zval *img; zval *dstw, *dsth; long sw,sh,dw,dh; Imlib_Image src,dst; if (zend_parse_parameters(3, "rzz", &img, &dstw, &dsth) == FAILURE) return; if ((src = (Imlib_Image)zend_fetch_resource(Z_RES_P(img), le_imlib_img_name, le_imlib_img)) == NULL) RETURN_FALSE; convert_to_long_ex(dstw); convert_to_long_ex(dsth); dw = Z_LVAL_P(dstw); dh = Z_LVAL_P(dsth); if (!dw && !dh) { RETURN_FALSE; } imlib_context_set_image(src); sw = imlib_image_get_width(); sh = imlib_image_get_height(); if (!dw) { dw = (long) (((double)dh * sw) / sh); } if (!dh) { dh = (long) (((double) dw * sh) / sw); } dst = imlib_create_cropped_scaled_image(0,0, sw,sh, dw,dh); if (dst) RETURN_RES(zend_register_resource(dst, le_imlib_img)); } /* }}} */ /* {{{ proto bool imlib_dump_image(int img[, int &err[, int quality]]) Output an image at an optional quality setting */ PHP_FUNCTION(imlib_dump_image) { int argc, retval; zend_long q; FILE *tmp; zend_string *tmpfile; zval *img, *err; Imlib_Image im; Imlib_Load_Error im_err; argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc, "r|zl", &img, &err, &q) == FAILURE) return; if (argc > 1) { zval_dtor(err); ZVAL_LONG(err,0); } if ((im = (Imlib_Image)zend_fetch_resource(Z_RES_P(img), le_imlib_img_name, le_imlib_img)) == NULL) RETURN_FALSE; tmp = php_open_temporary_file("", "", &tmpfile); if (tmp == NULL) { php_error_docref(NULL, E_WARNING, "Unable to open temporary file"); RETURN_FALSE; } imlib_context_set_image(im); if(!imlib_image_format()) { imlib_image_set_format("png"); } if (argc > 2) { imlib_image_attach_data_value("quality",NULL,q,NULL); } imlib_save_image_with_error_return(tmpfile->val,&im_err); if (im_err) { if (argc > 1) { ZVAL_LONG(err,im_err); } _php_handle_imlib_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, im_err,tmpfile->val); fclose(tmp); VCWD_UNLINK(tmpfile->val); /* make sure that the temporary file is removed */ zend_string_release(tmpfile); RETURN_FALSE; } else { char buf[4096]; /* fseek or something, then read the file and dump it out. */ fseek(tmp, 0, SEEK_SET); #if APACHE && defined(CHARSET_EBCDIC) SLS_FETCH(); /* This is a binary file already: avoid EBCDIC->ASCII conversion */ ap_bsetflag(php3_rqst->connection->client, B_EBCDIC2ASCII, 0); #endif while ((retval = fread(buf, 1, sizeof(buf), tmp)) > 0) { php_write(buf, retval); } fclose(tmp); VCWD_UNLINK(tmpfile->val); /* make sure that the temporary file is removed */ zend_string_release(tmpfile); RETURN_TRUE; } } /* }}} */ /* {{{ proto void imlib_free_color_range(int cr) Free a color range */ PHP_FUNCTION(imlib_free_color_range) { zval *fcr; Imlib_Color_Range cr; if (zend_parse_parameters(1, "r", &fcr) == FAILURE) return; if ((cr = (Imlib_Color_Range)zend_fetch_resource(Z_RES_P(fcr), le_imlib_cr_name, le_imlib_cr)) == NULL) RETURN_FALSE; zend_list_close(Z_RES_P(fcr)); } /* }}} */ /* {{{ proto void imlib_free_color_modifier(int cm) Free a color modifier */ PHP_FUNCTION(imlib_free_color_modifier) { zval *fcm; PHP_Imlib_Color_Modifier cm; if (zend_parse_parameters(1, "r", &fcm) == FAILURE) return; if ((cm = (Imlib_Color_Modifier)zend_fetch_resource(Z_RES_P(fcm), le_imlib_cm_name, le_imlib_cm)) == NULL) RETURN_FALSE; zend_list_close(Z_RES_P(fcm)); } /* }}} */ /* {{{ proto void imlib_free_font(int font) Free a font */ PHP_FUNCTION(imlib_free_font) { zval *font; PHP_Imlib_Font fn; if (zend_parse_parameters(1, "r", &font) == FAILURE) return; if ((fn = (PHP_Imlib_Font)zend_fetch_resource(Z_RES_P(font), le_imlib_font_name, le_imlib_font)) == NULL) RETURN_FALSE; zend_list_close(Z_RES_P(font)); } /* }}} */ /* {{{ proto void imlib_free_image(int img) Free an image */ PHP_FUNCTION(imlib_free_image) { zval *img; Imlib_Image im; if (zend_parse_parameters(1, "r", &img) == FAILURE) return; if ((im = (Imlib_Image)zend_fetch_resource(Z_RES_P(img), le_imlib_img_name, le_imlib_img)) == NULL) RETURN_FALSE; zend_list_close(Z_RES_P(img)); } /* }}} */ /* {{{ proto void imlib_get_text_advance(int font, string str, int &horiz_adv, int &vert_adv, int direction) Determines the horizontal and vertical advance of a string if drawn with a given font in the specified direction*/ PHP_FUNCTION(imlib_get_text_advance) { zval *font; zval *thoriz_adv, *tvert_adv; PHP_Imlib_Font fn; char *text = NULL; size_t text_len; int horiz_adv, vert_adv; zend_long dir; if (zend_parse_parameters(5, "rszzl", &font, &text, &text_len, &thoriz_adv, &tvert_adv, &dir) == FAILURE) return; if ((fn = (PHP_Imlib_Font)zend_fetch_resource(Z_RES_P(font), le_imlib_font_name, le_imlib_font)) == NULL) RETURN_FALSE; imlib_context_set_font(fn->font); imlib_context_set_direction(dir); imlib_get_text_advance(text, &horiz_adv, &vert_adv); zval_dtor(thoriz_adv); zval_dtor(tvert_adv); ZVAL_LONG(thoriz_adv,horiz_adv); ZVAL_LONG(tvert_adv,vert_adv); } /* }}} */ /* {{{ proto void imlib_get_text_size(int font, string str, int &w, int &h, int direction) Determines the width and height of a string if drawn with a given font in the specified direction */ PHP_FUNCTION(imlib_get_text_size) { zval *font; zval *tw, *th; PHP_Imlib_Font fn; char *text = NULL; size_t text_len; int w,h; zend_long dir; if (zend_parse_parameters(5, "rszzl", &font, &text, &text_len, &tw, &th, &dir) == FAILURE) return; if ((fn = (PHP_Imlib_Font)zend_fetch_resource(Z_RES_P(font), le_imlib_font_name, le_imlib_font)) == NULL) RETURN_FALSE; zval_dtor(tw); zval_dtor(th); imlib_context_set_font(fn->font); imlib_context_set_direction(dir); imlib_get_text_size(text, &w, &h); ZVAL_LONG(tw,w); ZVAL_LONG(th,h); } /* }}} */ /* {{{ proto void imlib_image_blur(int img, int radius) Blur an ima