imanee/imanee

此包已被弃用,不再维护。未建议替代包。

PHP 图像处理库

1.2.2 2015-09-03 13:02 UTC

README

Build Status Documentation Status Coverage Status License Join the chat at https://gitter.im/imanee/imanee

Imanee 是一个简单的 PHP 图像处理库。它提供了创建缩略图、水印、文本写入、动态 GIF 等的简便流程和方便的方法。

查看我们的实时演示以获取使用示例。查看我们的文档以获取详细说明。

要求

Imanee 需要 PHP >= 5.4,以及以下 PHP 图像扩展之一: ImagickGD。建议使用 Imagick,因为它具有更多功能,包括动态 GIF 支持(GD 中不可用)。

安装

首先确保您已在 PHP 服务器上安装并启用了 Imagick 或 GD。如果系统未找到 Imagick,Imanee 将尝试使用 GD。

您可以通过 composer 容易地将 Imanee 添加到项目中

$ composer require imanee/imanee

入门

一些简单的示例以供您开始

###缩略图输出

header("Content-type: image/jpg");

$imanee = new Imanee('path/to/my/image.jpg');
echo $imanee->thumbnail(200, 200)->output();

###在图像上方中央写入文本

header("Content-type: image/jpg");

$imanee = new Imanee('path/to/my/image.jpg');
echo $imanee->placeText('imanee test', 40, Imanee::IM_POS_MID_CENTER)
            ->output();

###图像合成

header("Content-type: image/jpg");

$imanee = new Imanee('path/to/my/image.jpg');

/** places 4 different png images on the 4 corners of the original image */

echo $imanee->placeImage('img1.png', Imanee::IM_POS_TOP_LEFT)
    ->placeImage('img2.png', Imanee::IM_POS_TOP_RIGHT)
    ->placeImage('img3.png', Imanee::IM_POS_BOTTOM_LEFT)
    ->placeImage('img4.png', Imanee::IM_POS_BOTTOM_RIGHT)
    ->output()
;

###从图像数组创建动态 GIF

$frames[] = 'img01.png';
$frames[] = 'img02.png';
$frames[] = 'img03.png';
$frames[] = 'img04.png';

header("Content-type: image/gif");

echo Imanee::arrayAnimate($frames, 30);

###从目录中的文件创建动态 GIF

header("Content-type: image/gif");

echo Imanee::globAnimate('resources/*.jpg');

###强制使用 GD

header("Content-type: image/jpg");

$imanee = new Imanee('path/to/my/image.jpg', new GDResource());
echo $imanee->thumbnail(200, 200)->output();

有关更多(和完整)示例,请查看演示存储库:https://github.com/imanee/demos