Code Monkey home page Code Monkey logo

image's Introduction

易始图片处理组件

(原 windwork image 组件重构)

支持图片缩略图和打水印,兼容各种第三方云存贮。 处理图片后,为方便云存贮处理,不直接保存图片,而是返回图片二进制内容。

安装

通过composer安装

composer require estart/image

生成缩略图

use EStart\\image\\ImageFactory;

// 设置源图片内容
$img = ImageFactory::create((file_get_contents('src_image/1.png'));

// 生成200x200的缩略图,超过比例截掉
$imgContent = $img->thumb(200, 200);
// 保存图片
file_put_contents('dist_image/thumb.png.cut_100x200.jpg', $imgContent);

// 生成100x200的缩略图,超过比例则补白色背景
$imgContent = $img->thumb(100, 200, false);
// 保存图片
file_put_contents('dist_image/thumb.png.uncut_100x200.jpg', $imgContent);

// 打水印
$imgContent = $img->watermark('src_image/logo.png');
// 保存图片
file_put_contents('dist_image/water1.jpg', $imgContent);

TODO

  • gif动态图打水印后返回动态缩略图。
  • 增加支持使用ImageMagick库进行处理图片

image's People

Contributors

coderpan-com avatar

Stargazers

 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.