store fid of file_load into profile2 I programmed a multi-step form using the drupal form API. On the first page is
a user image file upload using the drupal managed field managed_file. When the form is stepped thru to the end and submitted, the already in the single steps validated data will be stored into profile2, by creating a profile2 object with profile_create and set the assign the fields.
This all works without problem. But how can I store the FID of the uploaded file to the profile2 user_image field? A s I saw in mysql, the file FID and the measurements of the image are stored in the field table.

I have this (file_load code snippet is untested) in the form submit step, where the data gets stored into profile2:

$profile = profile_create(array
    'user' =&gt; $new_user,
    'type' =&gt; 'main'));
$profile-&gt;field_firstname['und'][0]['value'] = $user_data_collection['t_1_1'];
// ... 
if (isset($user_data_collection['t_1_22'])) {
    $file = file_load($user_data_collection['t_1_22']);
    $file-&gt;status = FILE_STATUS_PERMANENT;
    file_save($file);

    $fid = $file-&gt;fid;

    // --- how can I store the FID, x and y measurements of the image?
    // ...
}
// ...   
profile2_save($profile);


Can somebody give me a hint? I was searching on google but did not find an answer to my question. Thanks in advance!

Update:
This is how I solved it now. Since I work with an "managed_file" Field in the form, and later for displaying the image file via the theme() fct I do not have to care about resizing. This is done due to the image cache / theme fct's with a properly defined image-style.

$profile = profile_create(array(
   'user' =&gt; $new_user,
   'type' =&gt; 'main'));

//...

if (isset($user_data_collection['t_1_22'])) {
   $file = file_load($user_data_collection['t_1_22']);
   // --- Flag that this file is permanent and should not be deleted.
   $file-&gt;status = FILE_STATUS_PERMANENT;
   // --- save file object to the database
   file_save($file);

   // --- get original x/y measurements for this image
   $img_info = image_get_info(drupal_realpath($file-&gt;uri));
   // --- store fid. x and y to profile 2
   $profile-&gt;field_image_user[
      'und'][0]['fid'] = $file-&gt;fid;
   $profile-&gt;field_image_user[
      'und'][0]['width'] = $img_info['width'];
   $profile-&gt;field_image_user[
      'und'][0]['height'] = $img_info['height'];
}

//...

// --- save profile data
profile2_save($profile);


So all seems to work and have the solution that I needed.
I think you are asking how to save user picture. Users table holds the place for picture.

$account = user_load($new_user-&gt;uid);
user_save($account, array('picture' =&gt; $fid));


EDIT

Profile2 module is based on entities using Entity API module. You can use entity_metadata_wrapper('profile2', $profile-&gt;pid) to get a metadata object. This object will hold the properties (native profile2 fields) and Fields (additional properties plugged in via field api or Field Admin UI)

$profile = profile2_load_by_user($account, 'main');
$profile_w = entity_metadata_wrapper('profile2', $profile-&gt;pid);
$proflie_w-&gt;field_myfield-&gt;value(); // This is a read operation
$proflie_w-&gt;field_myfield-&gt;set('new value'); // This is write operation
$proflie_w-&gt;save(); // Finaly save the things


You can bypass metadata wrapper.

$profile = profile2_load_by_user($account, 'main'); // Loading existing profile instance
OR
$profile = profile2_create(array('user' =&gt; $account, 'type' =&gt; 'main')); // Providing a new profile instance
$profile-&gt;field_myfield = "new value";
$profile-&gt;save();


NOTE: you can check all your listed properties using foreach operation on the wrapper object.
e.g.

$profile_w = entity_metadata_wrapper('profile2', $profile-&gt;pid);
foreach($profile_w as $key =&gt; $obj){
   debug($key) // give you name of your property