当前位置:Gxlcms > PHP教程 > 初学phalcon

初学phalcon

时间:2021-07-01 10:21:17 帮助过:3人阅读


这是我在phalcon中找到的关于image的文件,看了一下源码,大致了解了如何实现
image.zep文件中是定义了一个Image类,其中定义了一些常量
如下


在image文件夹中,adapter.zep中定义了一个抽象类Adapter,其中 定义了一些对象和很多方法,包括以下

public getImage () ... public getRealpath () ...
public getWidth () Image width public getHeight () Image
height public getType () Image type Driver dependent
public getMime () Image mime type
public resize ([unknown $width], [unknown $height],
[unknown $master]) Resize the image to the given size
public liquidRescale (unknown $width, unknown $height,
[unknown $deltaX], [unknown $rigidity]) This method scales the images
using liquid rescaling method. Only support Imagick
public crop (unknown $width, unknown $height, [unknown $offsetX],
[unknown $offsetY]) Crop an image to the given size
public rotate (unknown $degrees) Rotate the image by a given
amount public flip (unknown $direction) Flip the image along the
horizontal or vertical axis public sharpen (unknown $amount)
Sharpen the image by a given amount
public reflection (unknown $height, [unknown $opacity],
[unknown $fadeIn]) Add a reflection to an image
public watermark (unknown $watermark, [unknown $offsetX],
[unknown $offsetY], [unknown $opacity]) Add a watermark to an image
with the specified opacity public text (unknown $text,
[unknown $offsetX], [unknown $offsetY], [unknown $opacity],
[unknown $color], [unknown $size], [unknown $fontfile]) Add a text to
an image with a specified opacity public mask (unknown $watermark)
Composite one image onto another
public background (unknown $color, [unknown $opacity]) Set the
background color of an image public blur (unknown $radius) Blur
image public pixelate (unknown $amount) Pixelate image
public save ([unknown $file], [unknown $quality]) Save the image
public render ([unknown $ext], [unknown $quality]) Render the
image and return the binary string

摘自官方文档,未翻译。。。

adapterinterface.zep中定义了AdapterInterface接口,其中声明了许多方法

在adapter文件夹中,有两个文件分别 定义了两个子类以及许多方法。

Imagick.zep中定义的方法

public static check () Checks if Imagick is enabled
public __construct (unknown $file, [unknown $width],
[unknown $height]) \Phalcon\Image\Adapter\Imagick constructor
protected _resize (unknown $width, unknown $height) Execute a
resize.
protected _liquidRescale (unknown $width, unknown $height, unknown $deltaX, unknown $rigidity)
This method scales the images using liquid rescaling method. Only
support Imagick
protected _crop (unknown $width, unknown $height, unknown $offsetX, unknown $offsetY)
Execute a crop. protected _rotate (unknown $degrees) Execute a
rotation. protected _flip (unknown $direction) Execute a flip.
protected _sharpen (unknown $amount) Execute a sharpen.
protected _reflection (unknown $height, unknown $opacity, unknown $fadeIn)
Execute a reflection.
protected _watermark (unknown $image, unknown $offsetX, unknown $offsetY, unknown $opacity)
Execute a watermarking.
protected _text (unknown $text, unknown $offsetX, unknown $offsetY, unknown $opacity, unknown $r, unknown $g,unknown $b, unknown $size, unknown $fontfile)
Execute a text protected _mask (unknown $image) Composite one
image onto another
protected _background (unknown $r, unknown $g, unknown $b, unknown $opacity) Execute a background. protected _blur (unknown $radius) Blur image
protected _pixelate (unknown $amount) Pixelate image
protected _save (unknown $file, unknown $quality) Execute a save.
protected _render (unknown $extension, unknown $quality) Execute a
render. public __destruct () Destroys the loaded image to free up
resources. public getInternalImInstance () Get instance
public setResourceLimit (unknown $type, unknown $limit) Sets the
limit for a particular resource in megabytes
public getImage () inherited from Phalcon\Image\Adapter ...
public getRealpath () inherited from Phalcon\Image\Adapter ...
public getWidth () inherited from Phalcon\Image\Adapter Image
width public getHeight () inherited from Phalcon\Image\Adapter
Image height public getType () inherited
from Phalcon\Image\Adapter Image type Driver dependent
public getMime () inherited from Phalcon\Image\Adapter Image mime
type public resize ([unknown $width], [unknown $height],
[unknown $master]) inherited from Phalcon\Image\Adapter Resize the
image to the given size
public liquidRescale (unknown $width, unknown $height,
[unknown $deltaX], [unknown $rigidity]) inherited
fromPhalcon\Image\Adapter This method scales the images using liquid
rescaling method. Only support Imagick
public crop (unknown $width, unknown $height, [unknown $offsetX],
[unknown $offsetY]) inherited fromPhalcon\Image\Adapter Crop an image
to the given size public rotate (unknown $degrees) inherited
from Phalcon\Image\Adapter Rotate the image by a given amount
public flip (unknown $direction) inherited
from Phalcon\Image\Adapter Flip the image along the horizontal or
vertical axis public sharpen (unknown $amount) inherited
from Phalcon\Image\Adapter Sharpen the image by a given amount
public reflection (unknown $height, [unknown $opacity],
[unknown $fadeIn]) inherited from Phalcon\Image\Adapter Add a
reflection to an image public watermark (unknown $watermark,
[unknown $offsetX], [unknown $offsetY], [unknown $opacity]) inherited
from Phalcon\Image\Adapter Add a watermark to an image with the
specified opacity public text (unknown $text, [unknown $offsetX],
[unknown $offsetY], [unknown $opacity], [unknown $color],
[unknown $size], [unknown $fontfile]) inherited
from Phalcon\Image\Adapter Add a text to an image with a specified
opacity public mask (unknown $watermark) inherited
from Phalcon\Image\Adapter Composite one image onto another
public background (unknown $color, [unknown $opacity]) inherited
from Phalcon\Image\Adapter Set the background color of an image
public blur (unknown $radius) inherited from Phalcon\Image\Adapter
Blur image public pixelate (unknown $amount) inherited
from Phalcon\Image\Adapter Pixelate image
public save ([unknown $file], [unknown $quality]) inherited
from Phalcon\Image\Adapter Save the image
public render ([unknown $ext], [unknown $quality]) inherited
from Phalcon\Image\Adapter Render the image and return the binary
string

Exception.zep中有如下方法

final private Exception __clone () inherited from Exception Clone
the exception public __construct ([string $message], [int $code],
[Exception $previous]) inherited from Exception Exception constructor
final public string getMessage () inherited from Exception Gets
the Exception message final public int getCode () inherited
from Exception Gets the Exception code
final public string getFile () inherited from Exception Gets the
file in which the exception occurred
final public int getLine () inherited from Exception Gets the line
in which the exception occurred
final public array getTrace () inherited from Exception Gets the
stack trace final public Exception getPrevious () inherited
from Exception Returns previous Exception
final public Exception getTraceAsString () inherited
from Exception Gets the stack trace as a string
public string __toString () inherited from Exception String
representation of the exception

我只是代码的搬运工,其中大部分都是文档上的,汇总一下,跪求大神能把官方文档翻译下来
看完这部分源代码,其实还是比较容易理解,然而时间有限没有深入了解,如果有机会要把每一个方法的实现再说一遍
第一次写这个,有问题一定要让我知道,逐渐努力

以上就介绍了初学phalcon,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行