Introduction - chung-leong/qb GitHub Wiki
QB stands for “Quick Binary.” It’s a PHP extension designed to enable faster handling of binary data. It takes a function written in PHP and translate it for a specialized virtual machine. The use of static type information leads significantly higher performance than under PHP’s regular dynamic type system. A PHP+QB function can run anywhere from five to twenty times faster than regular PHP code. For even higher level of performance, one can compile PHP+QB functions to native code (on supported platforms).
QB performs code translation on a per-function basis. It does not affect in anyway code not specially marked. Interaction between PHP+QB functions and regular PHP code is basically seamless. A key design objective of QB is to let developers harness greater processing power than what baseline PHP offers without the risk involved in adopting a brand new platform.
Potential Applications
QB is designed first and foremost for image processing. To this end, the QB virtual machine is endowed with the ability to quickly perform operations such as bi-linear sampling and matrix multiplication. QB works with PHP's GD library. When a GD image resource is passed to a QB function, it is converted to a multidimensional array of floating point numbers, which you can then freely manipulate.
One key QB feature is its ability to import Adobe Pixel Bender kernels. This provides you with a large range of preexisting image filters. The following shows how a simple graphic (the QB logo) is given a metallic appearance with the help of Pixel Bender:
Additional examples can be seen at the Pixel Bender Gallery.
Other usage scenarios include Unicode character processing, hash functions, and binary file parsing. QB can potentially be useful in any situation where you need to perform low-level operations on binary data.