PHP

PHP,第1张

PHP

AFAIK,您必须使用图像函数imagecreatefromstring,imagejpeg创建图像。

$imageData = base64_depre($imageData);$source = imagecreatefromstring($imageData);$rotate = imagerotate($source, $angle, 0); // if want to rotate the image$imageSave = imagejpeg($rotate,$imageName,100);imagedestroy($source);

希望这会有所帮助。

PHP CODE WITH IMAGE DATA

$imageDataEnpred = base64_enpre(file_get_contents('sample.png'));$imageData = base64_depre($imageDataEnpred);$source = imagecreatefromstring($imageData);$angle = 90;$rotate = imagerotate($source, $angle, 0); // if want to rotate the image$imageName = "hello1.png";$imageSave = imagejpeg($rotate,$imageName,100);imagedestroy($source);

因此,以下是程序的php部分..

NOTE
注释的更改
Change is here

    $uploadedPhotos = array('photo_1','photo_2','photo_3','photo_4');     foreach ($uploadedPhotos as $file) {      if($this->input->post($file)){      $imageData = base64_depre($this->input->post($file)); // <-- **Change is here for variable name only**         $photo = imagecreatefromstring($imageData); // <-- **Change is here**                $this->session->set_userdata('upload_'.$file,'ant');                if(!$this->session->userdata('uploading_on_datetime')){         $this->session->set_userdata('uploading_on_datetime',time());        }         $datetime_upload = $this->session->userdata('uploading_on_datetime',true);                $new_dir = 'temp/user_'.$this->session->userdata('user_id',true).'_on_'.$datetime_upload.'/';        if(!is_dir($new_dir)){        @mkdir($new_dir);        }                // @file_put_contents( $new_dir.$file.'.jpg',imagejpeg($photo));        imagejpeg($photo,$new_dir.$file.'.jpg',100); // <-- **Change is here**      }    }


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4906325.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存