How to recalculate uploaded files' sizes in KB and update the values in the database? I use a shell command to look for all uploaded JPEG files above 500 K.B. (originals) and do JPEG compression on them. They get smaller in size, but Drupal still shows the originally uploaded file size. How to force a recalculation and update the database accordingly after JPEG optimization?
In Drupal 7 managed files have their filesize property updated upon saving in the file_save() function. So you can just load/save each resized files to have it updated in the DB accordingly.

//@TODO: Get list of $fids corresponding to resized-files
foreach ($fids as $fid) {
  $file = file_load($fid);
  // $file-&gt;filesize reflects old size
  file_save($file);
  // $file-&gt;filesize now reflects new size
}