All Projects → tpmanc → yii2-imagick

tpmanc / yii2-imagick

Licence: other
Class for working with Imagick

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to yii2-imagick

docker-php7
Docker image tailed to run PHP application
Stars: ✭ 18 (+5.88%)
Mutual labels:  yii2
yii2-linkable-behavior
Yii2 behavior to help creating urls easier
Stars: ✭ 12 (-29.41%)
Mutual labels:  yii2
service-skeleton
Microservice skeleton based on yii2 framework.
Stars: ✭ 14 (-17.65%)
Mutual labels:  yii2
yii2-console-migration
yii2命令行中使用migration备份和还原数据库
Stars: ✭ 35 (+105.88%)
Mutual labels:  yii2
leadshop
Leadshop是一款提供持续更新迭代服务的轻量级、高性能开源电商系统,前后端分离(uniapp +电商专用yii2.0),可视化DIY拖拽装修,旨在打造极致的用户体验! 支持微信小程序,公众号等
Stars: ✭ 168 (+888.24%)
Mutual labels:  yii2
yii2-rollbar
Rollbar for Yii2
Stars: ✭ 36 (+111.76%)
Mutual labels:  yii2
yii2-querybuilder
Extension for Yii2 Framework to work with jQuery QueryBuilder
Stars: ✭ 41 (+141.18%)
Mutual labels:  yii2
luya-bootstrap4
Bootstrap4 Assets and Helper classes like ActiveForm for LUYA and Yii2.
Stars: ✭ 18 (+5.88%)
Mutual labels:  yii2
phd5-app
💜 Universal web application built upon Docker, PHP & Yii 2.0 Framework
Stars: ✭ 71 (+317.65%)
Mutual labels:  yii2
examination
Yii2-basic 考试系统
Stars: ✭ 76 (+347.06%)
Mutual labels:  yii2
cheatera.pp.ua
cheatera.pp.ua - UNIT Factory students stat: lvl, projects, etc
Stars: ✭ 19 (+11.76%)
Mutual labels:  yii2
yii2-dingtalk
yii2钉钉接口
Stars: ✭ 23 (+35.29%)
Mutual labels:  yii2
php-framework-benchmark
php framework benchmark (include laravel、symfony、silex、lumen、slim、yii2、tastphp etc)
Stars: ✭ 17 (+0%)
Mutual labels:  yii2
yii2-switch-widget
Bootstrap Switch Widget for Yii2
Stars: ✭ 17 (+0%)
Mutual labels:  yii2
yii2-array-query
Yii2 component that allows for searching/filtering the elements of an array.
Stars: ✭ 34 (+100%)
Mutual labels:  yii2
yii2-rest-api
Yii 2 REST API Project Template
Stars: ✭ 36 (+111.76%)
Mutual labels:  yii2
yii2-content-tools
ContentTools editor implementation for Yii 2
Stars: ✭ 79 (+364.71%)
Mutual labels:  yii2
yii2-toastr
Yii2 - Javascript Toast Notifications
Stars: ✭ 25 (+47.06%)
Mutual labels:  yii2
yii2-league-oauth2-server
Yii 2.0 implementation of PHP league OAuth2 server interfaces
Stars: ✭ 29 (+70.59%)
Mutual labels:  yii2
yii2-vote
Provides voting for any model 👍 👎
Stars: ✭ 70 (+311.76%)
Mutual labels:  yii2

Yii 2 Imagick

Yii 2 class for working with Imagick.

Install via Composer

Run the following command

$ composer require tpmanc/yii2-imagick "*"

or add

$ "tpmanc/yii2-imagick": "*"

to the require section of your composer.json file.

Original image:

"Original"

Get size

$img = Imagick::open('./image.jpg');
$img->getWidth();
$img->getHeight();

Resize image

Imagick::open('./image.jpg')->resize(400, 300)->saveTo('./resized.jpg');
Imagick::open('./image.jpg')->resize(400, false)->saveTo('./resized.jpg');

"Resize"

Create thumbnail

Imagick::open('./image.jpg')->thumb(200, 200)->saveTo('./thumb.jpg');

"Thumb"

Add border

$width = 5;
$color = '#000'
Imagick::open('./image.jpg')->border($width, $color)->saveTo('./result.jpg');

"Resize"

$width = 10;
$color = '#A91AD4'
Imagick::open('./image.jpg')->border($width, $color)->saveTo('./result.jpg');

"Resize"

Vertical and horizontal mirror image

// vertical
Imagick::open('./image.jpg')->flip()->saveTo('./result.jpg');
// horizontal
Imagick::open('./image.jpg')->flop()->saveTo('./result.jpg');

"Flip"

"Flop"

Crop

$xStart = 0;
$yStart = 0;
$xEnd = 150;
$yEnd = 150;
Imagick::open('./image.jpg')->crop($xStart, $yStart, $xEnd, $yEnd)->saveTo('./result.jpg');

"Crop"

Blur

$radius = 8;
$delta = 5;
Imagick::open('./image.jpg')->blur($radius, $delta)->saveTo('./result.jpg');

"Blur"

Watermark

Set watermark position

Use $xPosition and $yPosition to set watermark position.

$xPosition should be 'left', 'right' or 'center'; $yPosition should be 'top', 'bottom' or 'center'.

$xPosition = 'left';
$yPosition = 'top';
Imagick::open('./image.jpg')->watermark('./watermark.png'), $xPosition, $yPosition)->saveTo('./result.jpg');

"Watermark"

$xPosition = 'right';
$yPosition = 'center';
Imagick::open('./image.jpg')->watermark('./watermark.png'), $xPosition, $yPosition)->saveTo('./result.jpg');

"Watermark"

Set watermark size

Use $xSize and $ySize to set watermark size. Valid values:

  • Number: $xSize = 100;, $ySize = 50

  • Percent of parent: $xSize = '100%';, $ySize = '50%'

  • 'auto' to save proportion: $xSize = '100%';, $ySize = 'auto'

  • false: $xSize = 100;, $ySize = false

$xPosition = 'center';
$yPosition = 'center';
$xSize = '100%';
$ySize = 'auto';
Imagick::open('./image.jpg')->watermark('./watermark.png'), $xPosition, $yPosition, $xSize, $ySize)->saveTo('./result.jpg');

"Watermark"

$xPosition = 'center';
$yPosition = 'center';
$xSize = '100%';
$ySize = '100%';
Imagick::open('./image.jpg')->watermark('./watermark.png'), $xPosition, $yPosition, $xSize, $ySize)->saveTo('./result.jpg');

"Watermark"

Set watermark offset

Use $xOffset and $yOffset to set offset from parent image border.

$xPosition = 'right';
$yPosition = 'bottom';
$xSize = false;
$ySize = false;
$xOffset = 50;
$yOffset = 50;
Imagick::open('./image.jpg')->watermark('./watermark.png'), $xPosition, $yPosition, $xSize, $ySize, $xOffset, $yOffset)->saveTo('./result.jpg');

"Watermark"

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].