I am not sure if there is any fixed from this, but nevertheless the problem as follows.
Problem: My client took a picture using iphone. As it was in a wrong orientation, he used the inbuilt photo editor in his phone to flip it to the correct orientation. However, when he uploads the photo from his mac,the photo actually returns to the wrong orientation.
On mac, the corrected picture was seen in the correct orientation. But when sent to a windows pc or uploaded to a linux server, the picture returns to it's original wrong orientation.
Is this a mac issue or otherwise? Or is there any fix that can be done in PHP script. The following is the php script that uploads the photo.
$file=array();
$listingid=$_POST['listing'];
if(!empty($_FILES['file'])){
foreach($_FILES['file']['name'] as $key=>$name){
$extt=pathinfo($name, PATHINFO_EXTENSION);
$name=$this->mediacontrol->generateUniqueKey(32);
$name.=".".$extt;
if($_FILES['file']['error'][$key]==0 && move_uploaded_file($_FILES['file']['tmp_name'][$key],"uploads/{$name}")){
$file['file_name']=$name;
$file['file_type']=$_FILES['file']['type'][$key];
$file['file_path']="uploads/{$name}";
$file['full_path']= base_url()."uploads/{$name}";
$ext=explode(".",$name);
$file['thumb_path']=base_url()."uploads/thumbnails/250/".$ext[0]."_thumb.".$ext[1];
$file['thumb_short']="uploads/thumbnails/250/".$ext[0]."_thumb.".$ext[1];
$file['link_folder']="uploads/";
$file['raw_name']="null";
$file['orig_name']="$name";
$file['client_name']="null";
$file['file_size']=$_FILES['file']['size'][$key];
$file['is_image']="1";
$file['image_width']="0";
$file['image_height']="0";
$file['image_type']=$_FILES['file']['type'][$key];
$file['image_size_str']="width:0px;height:0px;";
$id=$this->mediacontrol->insertData($file);
$file_id[]=$id;
$config['image_library'] = 'GD2';
$config['source_image'] = "".$file['file_path'];
$config['new_image']="uploads/thumbnails/250/";
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 250;
$config['height'] = 250;
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();
$this->listing_model->matchMedia($id,$listingid);
$this->listing_model->updateStage(1,$id);
echo "Successfully uploaded ".$name."<br>";
}
else{
echo "Something went terribly wrong when uploading".$name;
}
}
}
Please advise.
Thank you.