Coder Social home page Coder Social logo

image's Introduction

PHP Image 图片处理

GitHub release PHP version GitHub license

环境要求

  • PHP >=7.0

安装说明

composer require "shugachara/image"

使用方式

<?php 
use ShugaChara\Image\ImageDeal;

$imageUrl = app()->getPath() . '/4.png';
$imageUrlB = app()->getPath() . '/a.png';
$textFont = app()->getPath() . '/PINGFANG_HEAVY.TTF';
$textSize = 34;
$textColor = '#ffffff';

// 案例一
$imageDeal = new ImageDeal($imageUrl);
$imageDeal->setFont($textFont);
$imageDeal->setPos(4);
$imageDeal->setPosX(300);
$imageDeal->setPosY(-40);
$imageDeal->waterText('2019年下半年能', $textSize, $textColor);
$imageDeal->setPosX(300);
$imageDeal->setPosY(20);
$imageDeal->waterText('赚到钱吗?',  $textSize, $textColor);
$imageDeal->preview();

// 案例二
$imageDeal = new ImageDeal($imageUrl);
$imageDeal->setFont($textFont);
$imageDeal->setPos(4);
$imageDeal->setPosX(300);
// 文字自动换行
$lineSplit = $imageDeal->autoLineSplit('2019年下半年能赚到钱吗?', 340, $textSize);
$posY = -40;
foreach ($lineSplit as $item) {
    $imageDeal->setPosY($posY);
    $imageDeal->waterText($item, $textSize, $textColor);
    $posY += 60;
}
// 在线预览图片
$imageDeal->preview();

// 添加水印图片
$imageDeal->setPosX(0);
$imageDeal->waterImage($imageUrlB, 0, 0);

// 图片裁剪
$imageDeal->imageCrop(300, 200, 400, 100);

// 图片缩放
$imageDeal->imageThumb(900, 0);

// 保存图片
$imageDeal->save(app()->getPath() . '/out.png');

更新日志

请查看 CHANGELOG.md

贡献

非常欢迎感兴趣,愿意参与其中,共同打造更好PHP生态,Swoole生态的开发者。

  • 在你的系统中使用,将遇到的问题 反馈

联系

如果你在使用中遇到问题,请联系: [email protected]. 博客: kaka 梦很美

License MIT

image's People

Contributors

raylin666 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.