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

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

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

meriksk/php-image

Composer 安装命令:

composer require meriksk/php-image

包简介

PHP class to re-size and scale images

README 文档

README

Latest Stable Version License

The Image class offers a bunch of image processing features using GD or IMagick.

Requirements

  • PHP >=8.1

Supported Image Libraries

  • GD Library (>=2.0)
  • Imagick PHP extension (>=6.5.7)

Setup

The preferred way to install this extension is through Composer. If you do not have Composer, you may install it by following the instructions at getcomposer.org.

Either run

composer require meriksk/php-image

or add

"meriksk/php-image": "~1.0"

to your composer.json and run composer update

Usage

Open image

Because this class uses namespacing, when instantiating the object, you need to either use the fully qualified namespace:

$image = new \meriksk\PhpImage\Image($filename);

or alias it:

use \meriksk\PhpImage\Image;

$image = new Image($filename);

This class can use Imagick or GD extension - whichever is available. Imagick extension is preferred if is available. You can force the extension for manipulating images as follows:

$image = new Image($filename, Image::DRIVER_IMAGICK);

Save image

Library supports three formats of image: 'jpeg', 'png' and 'gif'. By default they quality is set to 75. When saving to disk or outputting into the browser, the script assumes the same output type and quality as input.

$image->save($filename);

Save in a different type to the source:

$image->save($filename, 60, 'png');

Output image

To render the image directly into the browser, you can call:

$image->toScreen(60, 'png');

Resize

resize

$image = $image->resize($width, $height, $allow_enlarge);

resize to width

$image = $image->resizeToWidth($width, $allow_enlarge);

resize to height

$image = $image->resizeToHeight($height, $allow_enlarge);

resize to best fit

$image = $image->resizeToBestFit($max_width, $max_height, $allow_enlarge);

resize to long side

$image = $image->resizeToLongSide($max, $allow_enlarge);

resize to short side

$image = $image->resizeToShortSide($max, $allow_enlarge);

Crop

manual crop

$image->crop($x, $y, $width, $height, $allow_enlarge);

automatic crop

$image->autoCrop($width, $height, $position);

Thumbnail

$image->thumbnail($width, $height, $fill, $allow_enlarge);

Rotate image

Rotating is counter clockwise;

Rotate on 90 degrees:

$image->rotate(90);

Rotate on 45 degrees, and fill empty field with white color:

$image->rotate(45, '#FFFFFF');

Flip image

Flip in vertical direction:

$image->flip();

Flip in horisontal direction:

$image->flip(Image::FLIP_HORIZONTAL);

Flip in both directions:

$image->flip(Image::FLIP_BOTH);

Filters

todo

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固