php - imagerotate when using move_uploaded_file -


trying counter issues uploaded images ios devices exif orientation kept causing them rotated sometimes.

i found many snippets on using imagerotate counter problem trying implement them.

for saving of image using:

$moveuploadedfile = move_uploaded_file($filetoupload["tmp_name"], $this->uploaddir . "/" . $newfilename); 

(taken bulletproof image upload class)

im fine making switch statement check exif data, cant make move_uploaded_file work.

i have tried (for testing) e.g:

$image = $filetoupload["tmp_name"]; $image = imagerotate($image, 90, 0); $moveuploadedfile = move_uploaded_file($image, $this->uploaddir . "/" . $newfilename); 

this giving me error of move_uploaded_file requesting string receiving resource instead.

any help?

here go sir

public function moveuploadedfile($tmp_name, $destination)     {            if(move_uploaded_file($tmp_name, $destination)){             $this->image_rotation();             return true;         } }     public function image_rotation(){         /* check if image rotated,          * , if it's rotates. fix it!          */         // $filename = __dir__ . '/'.$this->location .'/'. $this->name . '.' . $this->mime;         $filename = $this   ->fullpath;          $exif = exif_read_data($filename);         if (isset($exif['orientation']))         {           switch ($exif['orientation'])           {             case 3:              // need rotate 180 deg                   $degrees = 180;                   break ;              case 6:               // need rotate 90 deg clockwise                   $degrees = -90;                   break ;              case 8:               // need rotate 90 deg counter clockwise                   $degrees = 90;                   break ;           }              if (preg_match("/jpg|jpeg/", pathinfo($filename, pathinfo_extension)))             {                 $image_source = imagecreatefromjpeg($filename);                 $rotate = imagerotate($image_source, $degrees, 0);                 imagejpeg($rotate, $filename, 100);              }             if (preg_match("/png/", pathinfo($filename, pathinfo_extension)))             {                $image_source = imagecreatefrompng($filename);                $rotate = imagerotate($image_source, $degrees, 0);                imagepng($rotate, $filename, 100);             }             if (preg_match("/gif/", pathinfo($filename, pathinfo_extension)))             {                $image_source = imagecreatefromgif($filename);                $rotate = imagerotate($image_source, $degrees, 0);                imagepng($rotate, $filename, 100);             }              imagedestroy($image_source); //free memory             imagedestroy($rotate);  //free memory          } } 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -