public static function getImageFromFile($file, $override = array())
{
if (!file_exists($file)) {
throw new Horde_Exception_NotFound(sprintf(_("The file \"%s\" doesn't exist."), $file));
}
global $conf;
// Get the mime type of the file (and make sure it's an image).
$mime_type = Horde_Mime_Magic::analyzeFile($file, isset($conf['mime']['magic_db']) ? $conf['mime']['magic_db'] : null);
if (strpos($mime_type, 'image') === false) {
throw new Horde_Exception_NotFound(sprintf(_("Can't get unknown file type \"%s\"."), $file));
}
$image = array('image_filename' => basename($file), 'image_caption' => '', 'image_type' => $mime_type, 'data' => file_get_contents($file));
// Override the array e.g., if we're changing filename to something else.
if (count($override)) {
$image = array_merge($image, $override);
}
return $image;
}