kingjerod/php-image-tools 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kingjerod/php-image-tools

Composer 安装命令:

composer require kingjerod/php-image-tools

包简介

An image manipulation library utilizing Imagick.

README 文档

README

Build Status Coverage Status Software License

PHP library for image manipulation, uses modifiers to alter images. Simplifies some of the complicatedness of Imagick. Has a factory to help load remote images, and also find/manipulate images in folders.

Installation

This library requires PHP 5.4 and the Imagick PHP plugin to be installed. On some Unix systems this command should work:

sudo apt-get install php5-imagick

Once you have Imagick installed, use composer to install the library:

composer require kingjerod\php-image-tools

##Usage ImageTools has two main classes, the Image class and the Modifier class. The Modifier classes are used to change an image, either through resizing, cropping or adding text. Multiple modifiers can be applied to an image, and the same modifier can be applied to multiple images.

##Examples

###First use the factory to load an image:

$factory = new ImageFactory();
$image = $factory->createFromLocalFile('/images/apple.png');

###Once you have the image you can use different modifiers to change it: #####Scale an image:

$scale = new Scale(200, 300); //width, height
$image->modify($scale);
$image->save('/images/appleBig.png');

#####Change opacity:

$opacity= new Opacity(0.8); //80% opacity (mostly visible)
$image->modify($opacity);
$image->save('/images/appleBig.png');

#####Add a watermark:

$text = new Text(10, 40, 'Arial.tff', '#000', 0.3, 24, 'Copyright XYZ');
$image->modify($text);
$image->save('/images/appleCopyright.png');

#####Merge two images together

$image2 = $factory->createFromLocalFile('/images/orange.png');
$merge = new Merge(10, 20, $image2);
$image->modify($merge);
$image->save('/images/appleAndOrange.png');

#####Do a bunch of cool things

$image2 = $factory->createFromLocalFile('/images/orange.png');
$merge = new Merge(10, 20, $image2);
$image->modify($merge);
$text = new Text(10, 40, 'Arial.tff', '#000', 0.3, 24, 'Copyright XYZ');
$image->modify($text);
$opacity= new Opacity(0.8); //80% opacity (mostly visible)
$image->modify($opacity);
$image->save('/images/appleAndOrangeCrazy.png');

##Custom Modifiers Creating your own modifiers is easy. Simple create your own class, and implement the ModifierInterface. It has one function:

public function modify(Image $image);

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-24