您当前的位置: 首页 >  php

苗先生的PHP记录

暂无认证

  • 0浏览

    0关注

    190博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

PHP图片合成

苗先生的PHP记录 发布时间:2022-05-18 23:32:14 ,浏览量:0

这里使用了一个插件库, 依赖GD2或者Imagic扩展

composer require intervention/image
Requirements
  • PHP >=5.4
  • Fileinfo Extension
Supported Image Libraries
  • GD Library (>=2.0)
  • Imagick PHP extension (>=6.5.7)

这个非常好用 ,

内置了关于图片+图片 , 图片+文字等多种操作

不依赖任何框架也能使用

// 首先创建一张图片

// create a new image resource from file
$img = Image::make('public/foo.jpg');

// or create a new image resource from binary data
$img = Image::make(file_get_contents('public/foo.jpg'));

// create a new image from gd resource
$img = Image::make(imagecreatefromjpeg('public/foo.jpg'));

// create a new image directly from an url
$img = Image::make('http://example.com/example.jpg');

// create a new image directly from Laravel file upload
$img = Image::make(Input::file('photo'));


// 图片加图片
$img->insert('public/bar.png');  // 这里也可以使用多种方式添加 , 包括文件流  二进制等

// 图片尺寸修改
$img->resize(); 

// 图片加文字
$img->text(); 



文档: https://image.intervention.io/v2/api/resize

github : https://github.com/Intervention/image

关注
打赏
1665468453
查看更多评论
立即登录/注册

微信扫码登录

0.0357s