filr conversion

Hi everybody

i created a form for editing profile picture

I want to make sure that all the pictures are jpg, so i want to convert the file uploaded to .jpg

How can I do it.

i looked at this:

http://www.yiiframework.com/extension/imgresizer/

but i don’t knoy how to use the convert function in my controler




class UserController extends Controller{

   ...


          public function actionEditPicture(){

	  

	  

                $model = new User();

                if(isset($_POST["User"])){

                    

                    //get the picture from the form

                    $model->picture = CUploadedFile::getInstance($model, 'picture'); 

                    

                    //Save the Original picture with the User PublicID 

                    $model->picture->saveAs($_SERVER['DOCUMENT_ROOT'].Yii::app()->request->baseUrl.'/images/user/'.$userid;.'.jpg');

                    

                    $this->redirect('user-picture');

                        //redirect to success page

                }

                $profileUser = User::model()->findByPk(Yii::app()->user->id);	  	

                $this->render('profile_editpicture', array('profileUser'=>$profileUser,'model'=>$model));   

	}



Thank you for your help

I would choose a different extension, I use this one:

http://www.yiiframework.com/extension/image/

Very simple to use:




$image = Yii::app()->image->load('images/test.png'); // wherever you saved the image

$image->resize(400, 100)->rotate(-45)->quality(75)->sharpen(20);

$image->save('images/new-image.jpg');



yes but i think in this way yill not change the file structure, but will only change the extension itself. only

Apparently, the file is saved to the correct format based on the extension:

http://forum.kohanaframework.org/discussion/6725/image-upload/p1

Edit:

To confirm that, you could save the file as both jpg and png. If they come out with different file sizes, it’s a pretty safe assumption that a conversion is happening.

Thank you for your reply, and for this i created a script to convert images from png and gif to jpg :rolleyes: