如何删除此函数中的exif数据?

时间:2016-10-18 08:15:36

标签: php netbeans

它是我的功能,我不知道如何删除来自上传的图片的exif数据。谢谢)

$uploadedFiles = $request->getUploadedFiles();

        if ($uploadedFiles && $id) {

            $usersPath = '/collections/' . date('Y/m') . '/' . $id .'/';
            $uploadFolder = realpath(BASE_PATH . '/uploads');
            $uploadFolder .= $usersPath;
            $newName = md5(time() . serialize($uploadedFiles)); 

            $fileExtension = strtolower($uploadedFiles[0]->getExtension());
            $sourceImgPath = $uploadFolder .$newName .'.' .$fileExtension;

            if (!file_exists($uploadFolder)) {
                mkdir($uploadFolder, 0777, true );
            }

            if(in_array($fileExtension, array('jpg', 'jpeg', 'png', 'gif'))){

                if ($uploadedFiles[0]->moveTo($sourceImgPath)) {
                    $info = pathinfo($sourceImgPath);

                    if ($info) {
                        $file_path = $usersPath . $info['filename'] . '.' . $fileExtension;
                        (new \Rapid\Storage\CollectionsStorage())->editImage($id, $file_path);
                    } else {
                        $session->set('msg_error', $this->translate->_('There was an unexpected error with uploading the file'));
                    }
                }
               } 
        } else {
            $session->set('msg_error', $this->translate->_('Invalid file type'));
        }

2 个答案:

答案 0 :(得分:0)

这取决于您有权访问的图形库。

答案 1 :(得分:0)

这段代码应删除JPEG中的所有EXIF信息

s15