C#获取图片扩展名
代码:
private string GetImageExtension(MemoryStream ms)
{
try
{
Image image = Image.FromStream(ms); if (image.RawFormat.Guid == ImageFormat.Bmp.Guid) return ".bmp";
if (image.RawFormat.Guid == ImageFormat.Emf.Guid) return ".wmf";
if (image.RawFormat.Guid == ImageFormat.Exif.Guid) return ".exif";
if (image.RawFormat.Guid == ImageFormat.Gif.Guid) return ".gif";
if (image.RawFormat.Guid == ImageFormat.Icon.Guid) return ".icon";
if (image.RawFormat.Guid == ImageFormat.Jpeg.Guid) return ".jpg";
if (image.RawFormat.Guid == ImageFormat.MemoryBmp.Guid) return ".bmp";
if (image.RawFormat.Guid == ImageFormat.Png.Guid) return ".png";
if (image.RawFormat.Guid == ImageFormat.Tiff.Guid) return ".tiff";
if (image.RawFormat.Guid == ImageFormat.Wmf.Guid) return ".wmf"; return string.Empty;
}
catch
{
return string.Empty;
}
}
C#获取图片扩展名的更多相关文章
- C#根据byte前两位获取图片扩展名
C#根据byte前两位获取图片扩展名 /// <summary> /// 根据byte前两位获取图片扩展名 /// </summary> /// <param name= ...
- PHP获取文件扩展名的多种方法
PHP获取文件扩展名的N种方法. 第1种方法: function get_extension($file) { substr(strrchr($file, '.'), 1): } 第2种方法: fun ...
- python获取文件扩展名的方法(转)
主要介绍了python获取文件扩展名的方法,涉及Python针对文件路径的相关操作技巧.具体实现方法如下: 1 2 3 4 import os.path def file_extension(path ...
- python获取文件扩展名的方法
主要介绍了python获取文件扩展名的方法,涉及Python针对文件路径的相关操作技巧 import os.path def file_extension(path): ] print file_ex ...
- PHP中获取文件扩展名的N种方法
PHP中获取文件扩展名的N种方法 从网上收罗的,基本上就以下这几种方式: 第1种方法:function get_extension($file){substr(strrchr($file, '.'), ...
- PHP获取文件扩展名五种以上的方法和注释
在PHP面试中或者考试中会有很大几率碰到写出五种获取文件扩展名的方法,下面是我自己总结的一些方法 $file = ‘需要进行获取扩展名的文件.php’; //第一种,根据.拆分,获取最后一个元素的值f ...
- PHP中获取文件扩展名
function get_extension($file) { return substr(strrchr($file, '.'), 1) ; } function get_extension($fi ...
- PHP获取文件扩展名的五种方式
这是我应聘实习时遇到的一道笔试题: 使用五种以上方式获取一个文件的扩展名. 要求:dir/upload.image.jpg,找出 .jpg 或者 jpg , 必须使用PHP自带的处理函数进行处理,方法 ...
- PHP 获取文件扩展名的五种方式
第一种 substr(strrchr("http://www.xxx.com/public/abc.jpg", '.'), 1); string strrchr('string', ...
随机推荐
- Windows下cpu使用的监控
这里有一篇来自微软的文章,主要讲WPA如何使用,但是前面关于进程调度的介绍很给力,非常好的学习操作系统的材料: https://msdn.microsoft.com/en-us/library/jj6 ...
- leetcode112
/** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNo ...
- php执行linux函数
function B(){ if(defined('LOCK') && LOCK == 'lock') return false; $addPort = sprintf('-A INP ...
- django多对多数据库建立 以及数据的传输 并进行增加 删除 修改
多对多数据库的建立 class Host(models.Model): nid = models.AutoField(primary_key=True) #自增id hostname = models ...
- JPA with Hibernate implementation
https://code.google.com/p/jpa-basics-tutorial/source/checkout http://alextretyakov.blogspot.com/2013 ...
- 关于document.cookie的使用
设置cookie每个cookie都是一个名/值对,可以把下面这样一个字符串赋值给document.cookie:document.cookie="userId=828";如果要一次 ...
- tomcat 域名直接访问默认工程,而不添加项目路径
<Engine name="Catalina" defaultHost="xx.xx.xx.xx"> <!--For clustering, ...
- confd test
vi /etc/confd/confd.toml backend = "consul"confdir = "/etc/confd"log-level = &qu ...
- python之with...as
[python之with...as] 参考:http://python.42qu.com/11155501
- 搭建双系统win10+ubuntu17.10
0. 序言 这里采用先装win10,再装ubuntu的顺序.这样可以避免后面系统启动项设置的问题.都采用UEFI引导方式,且使用usb2.0的u盘来引导(3.0的话,要准备好3.0的驱动).另外注意的 ...