artemeon/image

此包已被废弃且不再维护。未建议替代包。

简单图像处理

v0.1.2 2020-05-18 20:37 UTC

This package is auto-updated.

Last update: 2023-09-13 08:30:33 UTC


README

用于操作和输出图像的类。

此类可用于加载或创建图像,应用多种操作,如缩放和旋转,并保存结果图像。默认情况下,处理后的图像将被缓存,如果存在缓存版本,则不会进行任何处理。

示例

$image = new Image();
$image->load("/files/images/samples/PA252134.JPG");
 
// Scale and crop the image so it is exactly 800  600 pixels large.
$image->addOperation(new ImageScaleAndCrop(800, 600));

// Render a text with 80% opacity.
$image->addOperation(new ImageText("Kajona", 300, 300, 40, "rgb(0,0,0,0.8)")
 
// Apply the operations and send the image to the browser.
if (!$image->sendToBrowser()) {
    echo "Error processing image.";
}

可以通过实现 ImageOperationInterface 添加自定义操作。大多数操作应继承自 ImageAbstractOperation,它实现了 ImageOperationInterface 并提供了常用功能。