LoginSignup
0
1

More than 5 years have passed since last update.

Upload pack スマホの回転対応する方法

Posted at

スマホの回転リサイズに対応するには。。。。

Cakeのroot/app/Plugin/upload_pack/Model/Behavior/UploadBehavior.php

    private function _resize($srcFile, $destFile, $geometry, $quality = 75, $alpha = false) {

        copy($srcFile, $destFile);
        @chmod($destFile, 0777);
        $pathinfo = UploadBehavior::_pathinfo($srcFile);
        $src = null;
        $createHandler = null;
        $outputHandler = null;
        $imgFrame = new Imagick($destFile);

        $orientation = 0;
        if(method_exists($imgFrame, "getImageOrientation") ){
            $orientation = $imgFrame->getImageOrientation();
        }
        if(!$orientation && function_exists("read_exif_data")){
            $exif = read_exif_data($imgFrame);
            $orientation = $exif['Orientation'];
        }

        $rotetation = 0;
        switch((int)$orientation) {
            case 0:
                break;
            case 1:
                break;
            case 2:
                $imgFrame->flopImage();
                break;
            case 3:
                $imgFrame->rotateImage(new ImagickPixel(), 180 );
                break;
            case 4:
                $imgFrame->flipImage();
                break;
            case 5:
                $imgFrame->rotateImage(new ImagickPixel(), 270 );
                $imgFrame->flipImage();
                break;
            case 6:
                $imgFrame->rotateImage(new ImagickPixel(), 90 );
                break;
            case 7:
                $imgFrame->rotateImage(new ImagickPixel(), 90 );
                $imgFrame->flipImage();
                break;
            case 8:
                $imgFrame->rotateImage(new ImagickPixel(), 270 );
                break;
        }
        $imgFrame->writeImages($destFile, TRUE);
以下略```
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1