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:

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

class UserController extends Controller{


          public function actionEditPicture(){



                $model = new User();



                    //get the picture from the form

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


                    //Save the Original picture with the User PublicID 




                        //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:

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);


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:


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: