Programmatically save image together with its ALT
As far as Drupal 8 is concerned, there is another solution :

//    $file : my File Entity
//    $node : my (Node) Entity having an Image File field associated
$node-&gt;field_my_image_field[] = [
 'target_id' =&gt; $file-&gt;id(),
 'alt' =&gt; 'Alt. text',
];
$node-&gt;save();


Well, I think that 'width', 'height' and 'title' are also available in the setting array (but target_id seems required).
cf: https://api.drupal.org/api/drupal/core%21modules%21image%21src%21Plugin%21Field%21FieldType%21ImageItem.php/class/ImageItem/8.2.x
(look at the source code, generateSampleValue() method).