zoukankan      html  css  js  c++  java
  • 处理图片出现翻转的问题

    首先保证   php   开   exif  扩展

     function rote($file){
        $imagemodel = new Image();
             $info = $imagemodel::GetImageInfo($file);
             $type = empty($type) ? $info['type'] : $type;
             $type = strtolower($type);
             unset($info);
             $image = imagecreatefromstring(file_get_contents($file));
             //file_put_contents($log, $image.' ');
            $exif = @exif_read_data($file);
           if(isset($exif['Orientation']) && !empty($exif['Orientation'])) {
                                   switch($exif['Orientation']) {
                                                  case 8:
                                                  $image = imagerotate($image,90,0);
                                                  break;
                                                  case 3:
                                                  $image = imagerotate($image,180,0);
                                                  break;
                                                  case 6:
                                                 $image = imagerotate($image,-90,0);
                                                 break;
                                  }
             }
        $imageFun = 'image' . ($type == 'jpg' ? 'jpeg' : $type);
        $imageFun($image,$file);
        imagedestroy($image);    
     }

  • 相关阅读:
    微擎开发------day02
    微擎开发------day01
    Myisam 和 Innodb 区别
    Curl的简单使用步骤
    微信小程序之----获取设备信息
    微信小程序之 -----事件
    微信小程序之---- 数据处理
    微信小程序之----制作视频弹幕
    cocos2dx安卓客户端接入移动MM付费SDK
    Win7 / Win8 搭建配置【vs2010】、【cocos2dx环境】、【Android平台】
  • 原文地址:https://www.cnblogs.com/lijiageng/p/5741486.html
Copyright © 2011-2022 走看看