ThinkPHP/Library/Think/Image/Driver/Imagick.class.php

(开头部分) 19KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
// +----------------------------------------------------------------------
// | TOPThink [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2010 http://topthink.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
// | ImageImagick.class.php 2013-03-06
// +----------------------------------------------------------------------
namespace Think\Image\Driver;
use Think\Image;
class Imagick{
    /**
     * 图像资源对象
     * @var resource
     */
    private $img;

    /**
     * 图像信息,包括width,height,type,mime,size
     * @var array
     */
    private $info;

    /**
     * 构造方法,可用于打开一张图像
     * @param string $imgname 图像路径
     */
    public function __construct($imgname = null) {
        $imgname && $this->open($imgname);
    }

    /**
     * 打开一张图像
     * @param  string $imgname 图像路径
     */
    public function open($imgname){
        //检测图像文件
        if(!is_file($imgname)) E('不存在的图像文件');

        //销毁已存在的图像
        empty($this->img) || $this->img->destroy();

        //载入图像
        $this->img = new \Imagick(realpath($imgname));

        //设置图像信息
        $this->info = array(
            'width'  => $this->img->getImageWidth(),
            'height' => $this->img->getImageHeight(),
            'type'   => strtolower($this->img->getImageFormat()),
            'mime'   => $this->img->getImageMimeType(),
        );
    }

    /**
     * 保存图像
后面还有 533 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。