定制 acoustep/canvas 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

acoustep/canvas

Composer 安装命令:

composer require acoustep/canvas

包简介

Simple GD Library class for resizing images

README 文档

README

Canvas is a simple PHP class for creating and manipulating image sizes with the GD Library.

Usage

Setting up the canvas

There are two ways to set up the canvas.

  1. Through the constructor
$canvas = \Acoustep\Canvas(500, 250, '#000000');
  1. Through methods
$canvas = \Acoustep\Canvas()->width(500)->height(250)->background('#000000');

Adding images

Images are added through the image method, you can add as many layers as you would like.

The first image added will be added to the bottom of the output. The rest will be layered on top of each other in the order they were added.

The image method takes two arguments: A string (The file along with the path to the file) and an array of arguments.

$canvas = \Acoustep\Canvas()->width(500)
							->height(250)
							->background('#000000')
							->image('images/test.jpg', array('x' => 'left',
											                 'y' => 'top',
											                 'scale' => 'best'));

X can be an integer which is the offset from the canvas in pixels or left, centre or right.

Y can also be an integer for a specific offset, top, middle or bottom

Scale can be width, height, best or false.

  • Width sets the image to fit best with the canvas width.
  • Height sets the image to fit best with the canvas height.
  • Best will try to figure out whether to use width or height for you.
  • False will keep the image size the same as it was originally.

Outputting the image

There are three methods to output the image to the user. output(), filetype() and create().

  • Filetype lets you set the image type. PNG, GIF and JPG are supported.
  • Output lets you specify a filename to output the image to. If NULL it will try to output to the current file - You will need to set the headers appropriately for it.
  • Create is used when you are ready to output the image to the user. This method is always called last.

Examples

Output to a file named 'output.png'

$canvas = \Acoustep\Canvas()->width(500)
							->height(250)
							->background('#000000')
							->image('images/test.jpg', array('x' => 'left',
											                 'y' => 'top',
											                 'scale' => 'best'))
							->filetype('png')
							->output('output')
							->create();

Output to the current page

header("Content-Type: image/png");
$canvas = \Acoustep\Canvas()->width(500)
							->height(250)
							->background('#000000')
							->image('images/test.jpg', array('x' => 'center',
											                 'y' => 'middle',
											                 'scale' => 'width'))
							->filetype('png')
							->output(NULL)
							->create();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-06-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固