Skip to content

Commit

Permalink
Merge pull request #1025 from dreamsxin/image_class
Browse files Browse the repository at this point in the history
Add Image class
  • Loading branch information
Phalcon committed Aug 8, 2013
2 parents 2c5df2d + 7862085 commit cf42b58
Show file tree
Hide file tree
Showing 15 changed files with 3,641 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ext/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,13 @@ mvc/model/query/scanner.c \
mvc/view/engine/volt/parser.c \
mvc/view/engine/volt/scanner.c \
annotations/parser.c \
annotations/scanner.c"
annotations/scanner.c \
image.c \
image/adapter.c \
image/adapterinterface.c \
image/exception.c \
image/adapter/gd.c \
image/adapter/imagick.c"

PHP_NEW_EXTENSION(phalcon, $phalcon_sources, $ext_shared)
PHP_ADD_EXTENSION_DEP([phalcon], [spl])
Expand Down
72 changes: 72 additions & 0 deletions ext/image.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

/*
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2013 Phalcon Team (http://www.phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to license@phalconphp.com so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <andres@phalconphp.com> |
| Eduar Carvajal <eduar@phalconphp.com> |
+------------------------------------------------------------------------+
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_phalcon.h"
#include "phalcon.h"

#include "Zend/zend_operators.h"
#include "Zend/zend_exceptions.h"
#include "Zend/zend_interfaces.h"

#include "kernel/main.h"
#include "kernel/memory.h"

/**
* Phalcon\Image
*
* Image manipulation support. Allows images to be resized, cropped, etc.
*
*<code>
* $image = new Phalcon\Image\Adapter\GD("upload/test.jpg");
* $image->resize(200, 200);
* $$image->save();
*</code>
*/


/**
* Phalcon\Image initializer
*/
PHALCON_INIT_CLASS(Phalcon_Image){

PHALCON_REGISTER_CLASS(Phalcon, Image, image, NULL, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);

// Resizing constraints
zend_declare_class_constant_long(phalcon_image_ce, SL("NONE"), 1 TSRMLS_CC);
zend_declare_class_constant_long(phalcon_image_ce, SL("WIDTH"), 2 TSRMLS_CC);
zend_declare_class_constant_long(phalcon_image_ce, SL("HEIGHT"), 3 TSRMLS_CC);
zend_declare_class_constant_long(phalcon_image_ce, SL("AUTO"), 4 TSRMLS_CC);
zend_declare_class_constant_long(phalcon_image_ce, SL("INVERSE"), 5 TSRMLS_CC);
zend_declare_class_constant_long(phalcon_image_ce, SL("PRECISE"), 6 TSRMLS_CC);

// Flipping directions
zend_declare_class_constant_long(phalcon_image_ce, SL("HORIZONTAL"), 11 TSRMLS_CC);
zend_declare_class_constant_long(phalcon_image_ce, SL("VERTICAL"), 12 TSRMLS_CC);

// Driver: GD, ImageMagick, etc
zend_declare_class_constant_long(phalcon_image_ce, SL("GD"), 21 TSRMLS_CC);
zend_declare_class_constant_long(phalcon_image_ce, SL("IMAGICK"), 22 TSRMLS_CC);

return SUCCESS;
}
22 changes: 22 additions & 0 deletions ext/image.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

/*
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2013 Phalcon Team (http://www.phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to license@phalconphp.com so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <andres@phalconphp.com> |
| Eduar Carvajal <eduar@phalconphp.com> |
+------------------------------------------------------------------------+
*/

extern zend_class_entry *phalcon_image_ce;

PHALCON_INIT_CLASS(Phalcon_Image);
Loading

0 comments on commit cf42b58

Please sign in to comment.