public static function createFromFile(PHPRtfLite $rtf, $file, $width = null, $height = null)
{
if (is_readable($file)) {
$stream = fopen($file, 'rb');
$pathInfo = pathinfo($file);
$type = isset($pathInfo['extension']) ? strtolower($pathInfo['extension']) : 'jpeg';
$image = self::create($rtf, $stream, $type, $width, $height);
if ($type != self::TYPE_WMF) {
list($width, $height, $imageType) = getimagesize($file);
$imageType = image_type_to_extension($imageType, false);
$image->setImageWidth($width);
$image->setImageHeight($height);
if ($type != $imageType) {
$image->setImageType($imageType);
}
}
return $image;
}
return self::createMissingImage($rtf, $width, $height);
}