Is there a function that can output an image?
You can use theme('image').

Supposing that $img contains the PHP object you reported, then the following code can be used to output the image.

$output = theme('image', $img-&gt;filepath); // Drupal 6.
$output = theme('image', array('path' =&gt; $img-&gt;filepath)); // Drupal 7.