EDIT
Anyway I switched from node type to entity. The issue still present. I put test code to Drupal installation which is using database called 'gallery':
$e = entity_create('model', array('type' => 'image'));
$ew = entity_metadata_wrapper('model',$e);
$ew->field_entity_image_is_public->set(1);
$ew->field_entity_image->set(array(
'fid' => 12,
'alt' => 'alt',
'title' => 'title',
));
$ew->field_entity_image_name->set('image name');
$ew->save();
It works ok, but when I try to use similar snipper in other installation:
$file = file_load($image['fid']);
unset($file->fid);
$file->uid = 1;
db_set_active('gallery');
file_save($file);
$e = entity_create('model', array('type' => 'image'));
$ew = entity_metadata_wrapper('model',$e);
$ew->field_entity_image_is_public->set(1);
$ew->field_entity_image->set(array(
'fid' => $file->fid,
'alt' => $image['alt'],
'title' => $image['title'],
));
$ew->field_entity_image_name->set($file->filename);
$ew->save();
db_set_active();
Custom fields are not stored. Only record in file_managed table is inserted correctly.
All Drupal installations are on the same server so I thought that I can just switch to other installation database, but now I start thinking about using somekind of web service but it is pointless in this case :/