如何通过c#读写图片(JPG格式)的摘要信息

如题请大虾们帮帮忙右击jpg文件》属性》摘要我想读和写这里的信息(标题主题作者等等。。。)信息不是要照片曝光光圈那些数据的值... 如题 请大虾们帮帮忙
右击jpg文件》属性》摘要 我想读和写这里的信息(标题 主题 作者等等。。。 )信息 不是要照片曝光 光圈那些数据的值
展开
 我来答
善忆实用记忆方法
2010-06-21 · 超过10用户采纳过TA的回答
知道答主
回答量:39
采纳率:0%
帮助的人:28.2万
展开全部
using System;
using System.Collections.Generic;
using System.Text;

namespace SnhjCms.Common
{
/// <summary>
/// 图片处理类
/// </summary>
public static class PictureUtil
{
/// <summary>
/// 生成图片缩略图
/// </summary>
/// <param name="imgPath">原图片路径</param>
/// <param name="breviaryPath">缩略图路径</param>
/// <param name="width">缩略图宽度</param>
/// <param name="height">缩略图高度</param>
/// <param name="mode">生成方式</param>
public static void MakeBreviaryPhoto(string imgPath, string breviaryPath, int width, int height, string mode)
{
System.Drawing.Image image = System.Drawing.Image.FromFile(imgPath);
int x = 0, y = 0;
int w = image.Width;
int h = image.Height;

switch (mode)
{
case "HW"://指定高度和宽度缩放(图片会变形)
break;
case "W"://指定宽度缩放,高度按比例。
height = h * width / w;
break;
case "H"://指定高度缩放,宽度按比例。
width = w * height / h;
break;
case "Cut"://指定高度和宽度裁剪。
if ((double)w / (double)h > (double)width / (double)height)
{
w = h * width / height;
x = (image.Width - w) / 2;
}
else
{
h = w * height / width;
y = (image.Height - h) / 2;
}
break;
default:
break;
}

//创建一个bmp图片
System.Drawing.Image bmpImg = new System.Drawing.Bitmap(width, height);

//新建一个画板
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmpImg);

//设置高质量插值法
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;

//设置高质量,低速度呈现平滑程度
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

//清空画布并以透明背景色填充
g.Clear(System.Drawing.Color.Transparent);

//在指定位置并且按指定大小绘制原图片的指定部分
g.DrawImage(image, new System.Drawing.Rectangle(0,0,width,height), new System.Drawing.Rectangle(x,y,w,h), System.Drawing.GraphicsUnit.Pixel);

try
{
//以jpg格式保存缩略图
bmpImg.Save(breviaryPath, System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch (Exception e)
{
throw e;
}
finally
{
image.Dispose();
bmpImg.Dispose();
g.Dispose();
}
}

/// <summary>
/// 加图片水印
/// </summary>
/// <param name="filename">文件名</param>
/// <param name="watermarkFilename">水印文件名</param>
/// <param name="watermarkStatus">图片水印位置:0=不使用 1=左上 2=中上 3=右上 4=左中 ... 9=右下</param>
/// <param name="quality">是否是高质量图片 取值范围0--100</param>
/// <param name="watermarkTransparency">图片水印透明度 取值范围1--10 (10为不透明)</param>

public static void AddImageSignPic(string Path, string filename, string watermarkFilename, int watermarkStatus, int quality, int watermarkTransparency)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(Path);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img);

//设置高质量插值法
//g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
//设置高质量,低速度呈现平滑程度
//g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
System.Drawing.Image watermark = new System.Drawing.Bitmap(watermarkFilename);

if (watermark.Height >= img.Height || watermark.Width >= img.Width)
{
return;
}

System.Drawing.Imaging.ImageAttributes imageAttributes = new System.Drawing.Imaging.ImageAttributes();
System.Drawing.Imaging.ColorMap colorMap = new System.Drawing.Imaging.ColorMap();

colorMap.OldColor = System.Drawing.Color.FromArgb(255, 0, 255, 0);
colorMap.NewColor = System.Drawing.Color.FromArgb(0, 0, 0, 0);
System.Drawing.Imaging.ColorMap[] remapTable = { colorMap };

imageAttributes.SetRemapTable(remapTable, System.Drawing.Imaging.ColorAdjustType.Bitmap);

float transparency = 0.5F;
if (watermarkTransparency >= 1 && watermarkTransparency <= 10)
{
transparency = (watermarkTransparency / 10.0F);
}

float[][] colorMatrixElements = {
new float[] {1.0f, 0.0f, 0.0f, 0.0f, 0.0f},
new float[] {0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
new float[] {0.0f, 0.0f, 1.0f, 0.0f, 0.0f},
new float[] {0.0f, 0.0f, 0.0f, transparency, 0.0f},
new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}
};

System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(colorMatrixElements);

imageAttributes.SetColorMatrix(colorMatrix, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap);

int xpos = 0;
int ypos = 0;

switch (watermarkStatus)
{
case 1:
xpos = (int)(img.Width * (float).01);
ypos = (int)(img.Height * (float).01);
break;
case 2:
xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
ypos = (int)(img.Height * (float).01);
break;
case 3:
xpos = (int)((img.Width * (float).99) - (watermark.Width));
ypos = (int)(img.Height * (float).01);
break;
case 4:
xpos = (int)(img.Width * (float).01);
ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
break;
case 5:
xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
break;
case 6:
xpos = (int)((img.Width * (float).99) - (watermark.Width));
ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
break;
case 7:
xpos = (int)(img.Width * (float).01);
ypos = (int)((img.Height * (float).99) - watermark.Height);
break;
case 8:
xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
ypos = (int)((img.Height * (float).99) - watermark.Height);
break;
case 9:
xpos = (int)((img.Width * (float).99) - (watermark.Width));
ypos = (int)((img.Height * (float).99) - watermark.Height);
break;
}

g.DrawImage(watermark, new System.Drawing.Rectangle(xpos, ypos, watermark.Width, watermark.Height), 0, 0, watermark.Width, watermark.Height, System.Drawing.GraphicsUnit.Pixel, imageAttributes);

System.Drawing.Imaging.ImageCodecInfo[] codecs = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders();
System.Drawing.Imaging.ImageCodecInfo ici = null;
foreach (System.Drawing.Imaging.ImageCodecInfo codec in codecs)
{
if (codec.MimeType.IndexOf("jpeg") > -1)
{
ici = codec;
}
}
System.Drawing.Imaging.EncoderParameters encoderParams = new System.Drawing.Imaging.EncoderParameters();
long[] qualityParam = new long[1];
if (quality < 0 || quality > 100)
{
quality = 80;
}
qualityParam[0] = quality;

System.Drawing.Imaging.EncoderParameter encoderParam = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qualityParam);
encoderParams.Param[0] = encoderParam;

if (ici != null)
{
img.Save(filename, ici, encoderParams);
}
else
{
img.Save(filename);
}

g.Dispose();
img.Dispose();
watermark.Dispose();
imageAttributes.Dispose();
}

/// <summary>
/// 在图片上生成图片水印
/// </summary>
/// <param name="Path">原服务器图片路径</param>
/// <param name="Path_syp">生成的带图片水印的图片路径</param>
/// <param name="Path_sypf">水印图片路径</param>
public static void AddWaterPic(string Path, string Path_syp, string Path_sypf)
{
System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
g.DrawImage(copyImage, new System.Drawing.Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel);
g.Dispose();

image.Save(Path_syp);
image.Dispose();
}
}
}
百度网友02a064f
2010-06-21 · TA获得超过233个赞
知道小有建树答主
回答量:228
采纳率:0%
帮助的人:171万
展开全部
  我晕,你说的那些也包括在那里面,你点jpg文件的摘要里的高级就能看到了。

  我找了下,这个完全可以满足你的要求。先摘录一部分

  --对于数码相机所拍摄出的图片,Exif信息非常重要。Exif是英语Exchangeable Image File(可交换图像文件)的缩写,最初由日本电子工业发展协会(JEIDA --Japan Electronic Industry Development Association) 制订,目前的版本是修改发表于1998年6月的2.1版。国际标准化组织(ISO)正在制订的相机文件设计标准(DCF -- Design role for Camera File system)可能以Exif2.1为基础。当然Exif2.2在2002年也已经出来了,官方网站上也进行了长篇累牍的介绍,但是应用还不够广泛。

  Exif 文件实际是JPEG文件的一种,遵从JPEG标准,只是在文件头信息中增加了有关拍摄信息的内容和索引图。所以你可以使用任何支持JPEG格式的图像工具软件观看或修改Exif文件,但,打开时可能看不到Exif信息,一旦修改,Exif信息可能丢失。

  很多软件都可以查看文件图片的Exif信息,包括最常用的看图软件ACDSee,但是如何自己获取图片的Exif信息呢?我所要的是把这个功能集成到我的项目中,就必须要自己提取图片的Exif信息。

  完整的你去这个网址看吧,里面还包括了源代码!!
  http://www.fish888.com/EXIF-t127871

参考资料: http://www.fish888.com/EXIF-t127871

本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
bxfc
2010-06-21 · TA获得超过872个赞
知道小有建树答主
回答量:1104
采纳率:0%
帮助的人:740万
展开全部
用image或者用文件读都可以
有属性可以选择你要读取的是哪些信息

例如
Image imagetst=New Image(Path);
string fromStr=imagetst.???;
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
张庆贺21
2010-06-24 · TA获得超过282个赞
知道答主
回答量:238
采纳率:0%
帮助的人:164万
展开全部
我现在也正在做这个,也找不到方法,可否加QQ聊一下啊?297500624。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式