ppypp伦理天堂,91手机在线视频,免费在线观看黄色毛片,夜夜穞天天穞狠狠穞AV美女按摩

聯(lián)系官方銷售客服

1835022288

028-61286886

解決方案
  • cms并不會進行旋轉圖片
  • 回復@迅??蚣苈?lián)合創(chuàng)始人 只有移動端上傳手機照片的時候會自動旋轉,如果開啟壓縮的話,縮略圖和原圖都會旋轉,不開啟壓縮只有縮略圖旋轉。

  • 感覺是手機拍攝角度的exif不一樣。

  • 問題找到了,就是手機拍攝角度影響了exif信息。修改了一下Image類,用exif擴展把圖片旋轉回來即可。


    // 圖片壓縮處理

    public function reduce($imgsrc, $cw) {

    list($width, $height, $type) = getimagesize($imgsrc);

    $angle = $this->detect_orientation($imgsrc);

    if ($angle===90 || $angle===270){

    $width = $height;

    $height = $width;

    }

    if ($width > $cw) {

    $per = $cw / $width;//計算比例

    $new_width = floor($width * $per); //壓縮后的圖片寬

    $new_height = floor($height * $per); //壓縮后的圖片高

    switch ($type) {

    case 1:

    // gif

    break;

    case 2:

    //header('Content-Type:image/jpeg');

    $image_wp = imagecreatetruecolor($new_width, $new_height);

    $image = imagecreatefromjpeg($imgsrc);

    if($angle) {

    $image = imagerotate($image, $angle, 0);

    }

    imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    //90代表的是質量、壓縮圖片容量大小

    imagejpeg($image_wp, $imgsrc, 100);

    imagedestroy($image_wp);

    imagedestroy($image);

    break;

    case 3:

    header('Content-Type:image/png');

    $image_wp = imagecreatetruecolor($new_width, $new_height);

    $image = imagecreatefrompng($imgsrc);

    if($angle) {

    $image = imagerotate($image, $angle, 0);

    }

    //2.上色

    $color=imagecolorallocate($image_wp,255,255,255);

    //3.設置透明

    imagecolortransparent($image_wp,$color);

    imagefill($image_wp,0,0,$color);

    imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    //90代表的是質量、壓縮圖片容量大小

    imagejpeg($image_wp, $imgsrc, 100);

    imagedestroy($image_wp);

    imagedestroy($image);

    break;

    case 18:

    header('Content-Type:image/webp');

    $image_wp = imagecreatetruecolor($new_width, $new_height);

    $image = imagecreatefromwebp($imgsrc);

    if($angle) {

    $image = imagerotate($image, $angle, 0);

    }

    imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    //90代表的是質量、壓縮圖片容量大小

    imagewebp($image_wp, $imgsrc, 100);

    imagedestroy($image_wp);

    imagedestroy($image);

    break;

    }

    } else {

    CI_DEBUG(@反饋BUG) && log_message('debug', '系統(tǒng)要求寬度>'.$cw.'px才進行壓縮處理,當前圖片寬度='.$width.',不滿足壓縮條件:'.$imgsrc);

    }

    return;

    }

    //檢測圖片的拍攝角度, 返回需要旋轉回正常的角度,需要開啟php的exif擴展

    public function detect_orientation($imgsrc) {

    if (function_exists('exif_read_data')) {

    $ori_type = exif_read_data($imgsrc)['Orientation'];

    switch ($ori_type) {

    case 6:

    return 270;

    case 3:

    return 180;

    case 8:

    return 90;

    default:

    return 0;

    }

    } else {

    return 0;

    }

    }