首页 > 其他分享 >webman使用 intervention/image 生成带水印/二维码的图片

webman使用 intervention/image 生成带水印/二维码的图片

时间:2023-03-30 15:55:06浏览次数:36  
标签:webman image share 二维码 file qrcode path intervention

一、使用composer下载扩展包

composer require intervention/image

 

二、实现代码

use Intervention\Image\ImageManager;

class Image
{
    private $image;
    
    public function __construct() 
    {
        $this->image = new ImageManager(array(
            'driver'    => 'imagick'
        ));
    }
/*
     *      分享图片添加二维码
     * 
     * 基底图片
     * 尺寸:750 * 1200
     * 空白二维码位置 top:100, left:50
     * 空白二维码尺寸 200 * 200
     * 
     */
    public function create($qrcode) 
    {      
        $base_image = public_path() . "/images/share_bg.png";
        
        $file_path = runtime_path() . "/temp/share/";
        
        if (!is_dir($file_path)) {
            mkdir($file_path, 0755, true);
        }
        
        $share_image = md5($qrcode) . mt_rand(0, 9999) . ".png";
        
        $this->image
                ->make($base_image)
                ->resize(750, 1200)
                ->insert($qrcode, 'top-left', 50, 100)
                ->save($file_path . $share_image);
                    
        return $file_path . $share_image;
    }    
}

 

备注: 图片添加水印类同

 

标签:webman,image,share,二维码,file,qrcode,path,intervention
From: https://www.cnblogs.com/liyong2019/p/17273036.html

相关文章

  • webman中使用Endroid/QrCode生成二维码
    一、使用composer下载扩展包composerrequireendroid/qr-code二、实现代码useEndroid\QrCode\Color\Color;useEndroid\QrCode\Encoding\Encoding;useEndroid\Q......
  • Android开发-Android常用组件-ImageView图像视图
    4.4 ImageView(图像视图)ImageView见名知意,就是用来显示图像的一个View或者说控件 需掌握的知识点:ImageView的src属性和blackground的区别;adjustViewBounds设置......
  • test3-new-version-fix-image-upload
    Advertisement:)pica-highqualityandfastimageresizeinbrowser.babelfish-developerfriendlyi18nwithpluralssupportandeasysyntax.Youwil......
  • KVM 使用 Centos CLoud Image 安装虚拟机
    1下载镜像#资源地址:https://cloud.centos.org/centos/7/images/wgethttps://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2c2拷贝虚......
  • cvCreateImage
    cvCreateImage是openCV中的一个函数。OpenCV是Intel公司支持的开放计算机视觉库。cvCreateImage:创建首地址并分配存储空间IplImage*cvCreateImage(CvSizesize,intd......
  • THFuse: An infrared and visible image fusion network using transformer and hybri
    THFuse:Aninfraredandvisibleimagefusionnetworkusingtransformerandhybridfeatureextractor一种基于Transformer和混合特征提取器的红外与可见光图像融合网......
  • php 截图(可预览) crop images thumb jcrop/asido
    jcrop+asido  index.php  <?php$targ_w=90;//thumbwidthsize$targ_h=89;//thumbheightsize$filename=$_GET['file'];if($filename){$abs=......
  • Ubuntu给Appimage创建快捷方式
    下载AppImageLauncher2.安装3.选择要运行的Appimage双击运行即可。他会在home目录下创建一个applications文件夹,并且帮你自动创建快捷方式。......
  • BufferedImage 详解
    1.继承依赖关系:2.介绍:BufferedImage子类描述具有可访问的图像数据缓冲区的图像。缓冲图像由图像数据的颜色模型和光栅组成。栅格采样模型中波段的数量和类型必须与颜......
  • Image-Line 的 FL Studio 21 新主题来啊
    自Image-Line发布FLStudio21以来,好奇的社区成员创造了新的好看的主题。我在网上查看了这些主题,并根据它们独特的外观和受欢迎程度选择了以下主题。不知道如何安装这些......