1,判断Image格式
用UE打开GIF/PNG/JPG格式的图片文件
我们会发现在文件头部某几个位置的字节的值连起来是'GIF'/'PNG'/'JFIF'
它们的位置分别如下:
GIF: 012
JFIF(JPG): 6789
PNG: 123
这样我们可以通过判断这几个字节值来得到Image文件格式:
String type = "";
byte b0 = image.getFileData()[0];
byte b1 = image.getFileData()[1];
byte b2 = image.getFileData()[2];
byte b3 = image.getFileData()[3];
byte b6 = image.getFileData()[6];
byte b7 = image.getFileData()[7];
byte b8 = image.getFileData()[8];
byte b9 = image.getFileData()[9];
// GIF
if (b0 == (byte) 'G' && b1 == (byte) 'I' && b2 == (byte) 'F')
type = "GIF";
// PNG
else if (b1 == (byte) 'P' && b2 == (byte) 'N' && b3 == (byte) 'G')
type = "PNG";
// JPG
else if (b6 == (byte) 'J' && b7 == (byte) 'F' && b8 == (byte) 'I' && b9 == (byte) 'F')
type = "JPG";
else
type = "Unknown";
image.setType(type);
2,判断Image大小
FileImageInputStream fiis = new FileImageInputStream(new File(image.getPath()));
image.setSize((float) fii.length() / 1000 + "KB");
3,判断Image宽度和高度
ImageIcon ii = new ImageIcon(image.getPath());
image.setHeight(String.valueOf(ii.getIconHeight()));
image.setWidth(String.valueOf(ii.getIconWidth()));
分享到:
相关推荐
image/gif image/tiff image/png width指定图片宽度 height指定图片高度 type方式: 0-按照指定的宽度和高度生成图片 1-以宽度(参数width)为基准,根据原始图片宽高比率生成新的图片高度 2-以高度...
if (i.MimeType == "image/jpeg" || i.MimeType == "image/bmp" || i.MimeType == "image/png" || i.MimeType == "image/gif") { ici = i; } } EncoderParameters ep = new EncoderParameters(1); ep.Param[0...
file_types_description : "文件类型", //文件格式描述 file_size_limit : "500 MB", // 文件大小限制 file_upload_limit : 5, //上传文件总数 button_append : "divAddFiles", button_width: 32, ...
if(image.width/image.height>= preW/preH){ if(image.width>preW){ ImgD.width=preW; ImgD.height=(image.height*preW)/image.width; }else{ ImgD.width=image.width; ImgD.height=image.height; } ImgD...
* The width/height of the output image. * If you specify only one dimension (width or height) the image will be scaled respecting the ratio. * If you specify both the image will be croped to the ...
图片大小 一个模块,用于获取任何图像文件的尺寸支持的格式骨形态发生蛋白UR DDS GIF 集成电路代币发行JPEG格式韩国电信PNG PNM(PAM,PBM,PFM,PGM,PPM) PSD素材SVG TIFF WebP程序用法npm install image-size --...
把图片文件(JPG GIF PNG)上传, 2。保存到指定的路径(在web.config中设置路径,以文件的原有格式保存), 3。并自动生成指定宽度的(在web.config中设置宽度) 4。和指定格式的(在web.config中指定缩略图的格式...
使用纯Ruby格式测量图像大小: apng , bmp , cur , gif , ico , j2c , jp2 , jpeg , jpx , mng , pam , pbm , pcx , pgm , png , ppm , psd , svg , swf , tiff , webp , xbm , xpm ...
支持的图像类型:JPG,GIF,PNG,WebP,BMP,TIFF,SVG,PSD,ICO,AVIF,HEIC,HEIF。 主要特征: 体积小,无严重依赖 处理远程和本地数据 适用于大图像(速度/内存),可从遥控器下载最少的数据 易于浏览(拆分...
*.png',//允许上传的文件类型,限制弹出文件选择框里能选择的文件 "method": 'post',//和后台交互的方式:post/get "multi": true,//是否能选择多个文件 "queueID": 'None_none',//显示上传文件队列的元素id,可以...
客户端/服务器检测扩展名, 验证文件大小, 无刷新上传!... 多个用|分隔,如gif|jpg|png Size 上传文件大小 (KB) 默认256KB TimeOut 上传超时设置 (秒), 默认30秒 CallBack Js回调函数名 <br>例:...
left:0}#pad-version{line-height:40px}.s_ipt_wr.bg,.s_btn_wr.bg,#su.bg{background-image:none}.s_btn_wr{width:auto;height:auto;border-bottom:1px solid transparent;*border-bottom:0}.s_btn{width:100px;...
Layer shadow = image.Layers.Add(width + shadowwidth, height + shadowwidth); SolidBrush brush = new SolidBrush(shadowcolor); shadow.FillRectangle(shadowwidth, shadowwidth, bmp.Width, bmp.Height, ...
ImageFormat=JPEG 生成图片格式,有bmp,gif,png,jpge,tif等 BarcodeType=Code39 生成编码方式,有EAN13,EAN8,UPCA等具体看Barcode1中的index.htm介绍 Data=F19865742 要生成的字符串 Width=200 图片宽度 Height=60...
功能:支持jpg,jpeg,gif,png,bmp图片格式,支持按原图片的比例进行缩放,可以选择在图片缩放的过程中是否需要对图片进行裁切,加入了图片质量控制,可以实现缩略图片质量最高化。完整类的代码如下: <?php /...
gradY = grayValues[((Math.Abs(i - 1)) % curBitmap.Height) * curBitmap.Width + (Math.Abs(j - 1) % curBitmap.Width)] + grayValues[((Math.Abs(i - 1)) % curBitmap.Height) * curBitmap.Width + j] + gray...
generator = new Gif2VCGenerator(width, height, count);// gif generator.write2out(new FileOutputStream(path "/2.gif")).close(); validCode = generator.text(); System.out.println...
支持jpg,jpeg,gif,png,bmp图片格式,支持按原图片的比例进行缩放,可以选择在图片缩放的过程中是否需要对图片进行裁切,加入了图片质量控制,可以实现缩略图片质量最高化。 完整类的代码如下: <?php /** * ...
<tr><th width="10%">盘符</th><th width="15%">类型</th><th width="20%">卷标</th><th width="15%">文件系统</th><th width="20%">总容量</th><th width="20%">可用空间</th></tr> On Error Resume Next Is...