• php的getimagesize方法详解


    getimagesize方法可以查看图片的详细信息,如下:

    > print_r(getimagesize('mnjpg.jpg'));
    Array
    (
        [0] => 2250         // 宽
        [1] => 1500         // 高
        [2] => 3            // 类型
        [3] => width="2250" height="1500"
        [bits] => 8
        [mime] => image/png
    )
    

    图片类型说明

    $imageTypeArray = array(
        0 => 'UNKNOWN',
        1 => 'GIF',
        2 => 'JPEG',
        3 => 'PNG',
        4 => 'SWF',
        5 => 'PSD',
        6 => 'BMP',
        7 => 'TIFF_II',
        8 => 'TIFF_MM',
        9 => 'JPC',
        10 => 'JP2',
        11 => 'JPX',
        12 => 'JB2',
        13 => 'SWC',
        14 => 'IFF',
        15 => 'WBMP',
        16 => 'XBM',
        17 => 'ICO',
        18 => 'COUNT'  
    );
    

    图片上传,以jpeg类型为例

    $old_image = imagecreatefromjpeg($image_url);
    $new_image = imagecreatetruecolor($width, $height);
    
    imagecopy($new_image, $old_image, 0, 0, $x1, $y1, $width, $height);
    
    ob_start();
    imagejpeg($new_image);
    $contents = ob_get_contents();
    ob_end_clean();
    
    imagedestroy($old_image);
    imagedestroy($new_image);
    
    // 新图片上传到图片服务器
    $url = 'xxx/upload';
    $client = Apf_Http_CurlClient::getInstance();
    $ret = $client->doPost($url, array('file' => base64_encode($contents)), array(), array(), 1000);
    $ret = json_decode($ret, true);
    
  • 相关阅读:
    原型和原型链
    面向对象
    git在idea中的使用,如何构远程git方仓库
    java maven 安装
    Kafka消费者APi
    Kafka生产者APi
    kafka基本概念
    redis常用命令
    redis.conf配置文件参数说明
    Redis.RedisNativeClient的方法get_Db 没有实现
  • 原文地址:https://www.cnblogs.com/chenguoli/p/7607234.html
Copyright © 2020-2023  润新知