zoukankan      html  css  js  c++  java
  • 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);
    
  • 相关阅读:
    逻辑分支中if小括号中的隐式转换
    逻辑运算符
    CSS——元素的显示与隐藏
    JS对象
    JS预解析与变量提升
    JS作用域
    JS函数
    CSS定位(position)
    JS数组
    JS分支结构与循环结构
  • 原文地址:https://www.cnblogs.com/chenguoli/p/7607234.html
Copyright © 2011-2022 走看看