-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp_fimage.cpp
More file actions
67 lines (53 loc) · 2.4 KB
/
php_fimage.cpp
File metadata and controls
67 lines (53 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//============================================================================
// Name : php_fimage.cpp
// Author : Kluev Andrew
// Version : 1.0
// License : BSD
// Description : Fast image processing library depended on OpenCV
//============================================================================
#include <phpcpp.h>
#include "fast_image_class.h"
extern "C" {
/**
* Function that is called by PHP right after the PHP process
* has started, and that returns an address of an internal PHP
* structure with all the details and features of your extension
*
* @return void* a pointer to an address that is understood by PHP
*/
PHPCPP_EXPORT void *get_module()
{
/**
* Static(!!!) Php::Extension object that should stay in memory
* for the entire duration of the process (that's why it's static)
*/
static Php::Extension PhpFastImage("FastImage", "1.1");
// Description of the class so that PHP knows which methods are accessible
Php::Class<FastImage> fastImage("FastImage");
fastImage.method("__construct", &FastImage::__construct, {
Php::ByVal("string", Php::Type::String),
});
fastImage.method("__destruct", &FastImage::__destruct);
fastImage.method("save", &FastImage::save, {
Php::ByVal("string", Php::Type::String),
});
fastImage.method("resize", &FastImage::resize, {
Php::ByVal("width", Php::Type::Numeric),
Php::ByVal("height", Php::Type::Numeric),
Php::ByVal("save_aspect_ratio", Php::Type::Numeric, false),
});
fastImage.method("crop", &FastImage::crop, {
Php::ByVal("x", Php::Type::Numeric),
Php::ByVal("y", Php::Type::Numeric),
Php::ByVal("w", Php::Type::Numeric),
Php::ByVal("h", Php::Type::Numeric),
});
fastImage.method("getWidth", &FastImage::getWidth, {});
fastImage.method("getHeight", &FastImage::getHeight, {});
fastImage.property("FAST_IMAGE_JPEG_QUALITY", FAST_IMAGE_JPEG_QUALITY, Php::Const);
fastImage.property("FAST_IMAGE_PNG_COMPRESSION", FAST_IMAGE_PNG_COMPRESSION, Php::Const);
fastImage.property("FAST_IMAGE_PXM_BINARY", FAST_IMAGE_PXM_BINARY, Php::Const);
PhpFastImage.add(std::move(fastImage));
return PhpFastImage;
}
}